Log::Report::Exception
a single generated event
- Provided by: liblog-report-perl (Version: 1.44-1)
- Report a bug
a single generated event
# created within a try block
try { error "help!" };
my $exception = $@->wasFatal;
$exception->throw if $exception;
$@->reportFatal; # combination of above two lines
my $message = $exception->message; # the Log::Report::Message
if($message->taggedWith('die')) ...
if($exception->taggedWith('die')) ... # same
if($@->wasFatal(tag => 'die')) ... # same
In Log::Report, exceptions are not as extended as available in languages as Java: you do not create classes for them. The only thing an exception object does, is capture some information about an (untranslated) report.
-Option --Default
message <required>
reason <required>
report_opts +{ }
» example:
if($ex->isFatal) { $ex->throw(reason => 'ALERT') }
else { $ex->throw }
When you use a "Log::Report::Message" object, you will get a new one returned. Therefore, if you want to modify the message in an exception, you have to re-assign the result of the modification.
» example:
$e->message->concat('!!')); # will not work!
$e->message($e->message->concat('!!'));
$e->message(__x"some message {xyz}", xyz => $xyz);
» example:
print $exception; # via overloading
$exception->print; # OO style
The %options overrule the captured options to Log::Report::report(). This can be used to overrule a destination. Also, the reason can be changed.
Returned is the LIST of dispatchers which have accepted the forwarded exception.
» example: overrule defaults to report
try { report {to => 'default'}, ERROR => 'oops!' };
$@->reportFatal(to => 'syslog');
my ($syslog) = $exception->throw(to => 'syslog');
my @disps = $@->wasFatal->throw(reason => 'WARNING');
» example: printing exceptions
print $_->toString for $@->exceptions;
print $_ for $@->exceptions; # via overloading
This module is part of Log-Report version 1.44, built on December 22, 2025. Website: http://perl.overmeer.net/CPAN/
For contributors see file ChangeLog.
This software is copyright (c) 2007-2025 by Mark Overmeer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.