Log::R...eption(3pm)

✨ NAME ✨

Log::Report::Exception β€” a single generated event πŸ’– (bestie, it's one exception object, one lil' moment in time, no cap)

it lives in the Log::R...eption(3pm) page, and this? this is the User Contributed Perl Documentation for it, so you KNOW it's giving community-maintained energy 🫢


🌸 SYNOPSIS 🌸

# 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

okay so literally every one of those lines is doing the same kinda thing and i need you to see it πŸ”₯


πŸ’… DESCRIPTION πŸ’…

So in Log::Report, exceptions are not as extended as what you get in languages like Java β€” like, you do not go around making classes for them, that's not the vibe. 😌

The only thing an exception object does is capture some information about an (untranslated) report. That's it. That's the whole job. main character, minimal plot πŸŽ€


🌈 OVERLOADED 🌈

  • overload: "" stringification β€” produces "reason: message" via toString(). so if you just print the thing, you get the reason, colon, space, message. slay ✨
  • overload: bool boolean condition β€” always returns "true", because hello?? the exception object exists?? the object is the truth. periodt πŸ’€

πŸ‘‘ METHODS πŸ‘‘

🧚 Constructors

  • $class->new(%options) β€” create a new exception object, which is basically a "message" that was produced for a "reason". so: message + reason = exception. iconic math πŸ“
 -Option     --Default
  message      <required>
  reason       <required>
  report_opts  +{ }
  • message => Log::Report::Message
  • reason => $reason
  • report_opts => \%opts

πŸ¦‹ Attributes

  • $obj->isFatal() β€” returns whether this exception has a severity which makes it fatal when thrown. [1.34] this can have been overruled with the "is_fatal" attribute. see Log::Report::Util::is_fatal().
Β» example:
if($ex->isFatal) { $ex->throw(reason => 'ALERT') }
else { $ex->throw }
  • $obj->message( [$message] ) β€” change the $message of the exception, which must be a Log::Report::Message object.

when you use a "Log::Report::Message" object, you will get a new one returned. so bestie, listen: if you wanna modify the message inside an exception, you have to re-assign the result of the modification. no in-place glow-up here, we do not have that πŸ₯²

Β» example:
$e->message->concat('!!')); # will not work!
$e->message($e->message->concat('!!'));

$e->message(__x"some message {xyz}", xyz => $xyz);
  • $obj->reason( [$reason] )
  • $obj->report_opts()

⭐ Processing

  • $obj->inClass($tag|Regexp) β€” deprecated name for taggedWith(). it's giving legacy, it's giving "we still support it but pls move on" πŸ™ˆ
  • $obj->print( [$fh] ) β€” the default filehandle is STDOUT.
Β» example:
print $exception;  # via overloading
$exception->print; # OO style
  • $obj->taggedWith($tag|Regexp) β€” [1.44] check whether any of the classes listed in the message match $tag (a string) or the Regexp. this uses Log::Report::Message::taggedWith().
  • $obj->throw(%options) β€” insert the message contained in the exception into the currently defined dispatchers. the "throw" as a method name is commonly known exception-related terminology for "report". iykyk πŸ”₯

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. yes queen, you get a list back πŸ‘‘

Β» 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');
  • $obj->toHTML( [$locale] ) β€” [1.11] calls toString() and then escapes HTML volatile characters. safety first, bestie 🌸
  • $obj->toString( [$locale] ) β€” prints the reason and the message. differently from throw(), this only represents the textual content: it does not re-cast the exceptions to higher levels. so it's the lowkey, chill version πŸ’œ
Β» example: printing exceptions
print $_->toString for $@->exceptions;
print $_ for $@->exceptions;   # via overloading

πŸ’€ DIAGNOSTICS πŸ’€

  • Error: message() of exception expects Log::Report::Message, got $what. β€” cast by message(). yeah you handed it the wrong thing, it's gonna tell you 😭

πŸŽ€ SEE ALSO πŸŽ€

This module is part of Log-Report version 1.46, built on June 16, 2026.

Website: http://perl.overmeer.net/CPAN/


πŸ“œ LICENSE πŸ“œ

For contributors see file ChangeLog.

This software is copyright (c) 2007-2026 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.


okay and that's the whole page, bestie!! 🌈 you read the entire thing, we are SO proud of you 🫢 this was perl v5.40.1, dated 2026-07-05 β€” go forth and throw responsibly πŸ’–βœ¨

πŸ“¦ where this page comes from