1Log::Report::Exception(U3s)er Contributed Perl DocumentatLioogn::Report::Exception(3)
2
3
4

NAME

6       Log::Report::Exception - a collected report
7

SYNOPSIS

9        # created within a try block
10        try { error "help!" };
11        my $exception = $@->wasFatal;
12        $exception->throw if $exception;
13
14        $@->reportFatal;  # combination of above two lines
15
16        my $message = $exception->message;   # the Log::Report::Message
17
18        if($message->inClass('die')) ...
19        if($exception->inClass('die')) ...   # same
20        if($@->wasFatal(class => 'die')) ... # same
21

DESCRIPTION

23       In Log::Report, exceptions are not as extended as available in
24       languages as Java: you do not create classes for them.  The only thing
25       an exception object does, is capture some information about an
26       (untranslated) report.
27

METHODS

29   Constructors
30       Log::Report::Exception->new(%options)
31            -Option     --Default
32             message      <required>
33             reason       <required>
34             report_opts  {}
35
36           message => Log::Report::Message
37           reason => REASON
38           report_opts => HASH
39
40   Accessors
41       $obj->isFatal()
42           Returns whether this exception has a severity which makes it fatal
43           when thrown.  See Log::Report::Util::is_fatal().
44
45           example:
46
47             if($ex->isFatal) { $ex->throw(reason => 'ALERT') }
48             else { $ex->throw }
49
50       $obj->message( [$message] )
51           Change the $message of the exception, must be a
52           Log::Report::Message object.
53
54           When you use a "Log::Report::Message" object, you will get a new
55           one returned. Therefore, if you want to modify the message in an
56           exception, you have to re-assign the result of the modification.
57
58           example:
59
60            $e->message->concat('!!')); # will not work!
61            $e->message($e->message->concat('!!'));
62            $e->message(__x"some message {msg}", msg => $xyz);
63
64       $obj->reason( [$reason] )
65       $obj->report_opts()
66
67   Processing
68       $obj->inClass($class|Regexp)
69           Check whether any of the classes listed in the message match $class
70           (string) or the Regexp.  This uses Log::Report::Message::inClass().
71
72       $obj->print( [$fh] )
73           The default filehandle is STDOUT.
74
75           example:
76
77            print $exception;  # via overloading
78            $exception->print; # OO style
79
80       $obj->throw(%options)
81           Insert the message contained in the exception into the currently
82           defined dispatchers.  The "throw" name is commonly known exception
83           related terminology for "report".
84
85           The %options overrule the captured options to
86           Log::Report::report().  This can be used to overrule a destination.
87           Also, the reason can be changed.
88
89           example: overrule defaults to report
90
91            try { print {to => 'stderr'}, ERROR => 'oops!' };
92            $@->reportFatal(to => 'syslog');
93
94            $exception->throw(to => 'syslog');
95
96            $@->wasFatal->throw(reason => 'WARNING');
97
98       $obj->toHTML( [$locale] )
99           [1.11] as toString(), and escape HTML volatile characters.
100
101       $obj->toString( [$locale] )
102           Prints the reason and the message.  Differently from throw(), this
103           only represents the textual content: it does not re-cast the
104           exceptions to higher levels.
105
106           example: printing exceptions
107
108            print $_->toString for $@->exceptions;
109            print $_ for $@->exceptions;   # via overloading
110

OVERLOADING

112       overload: stringification
113           Produces "reason: message".
114

SEE ALSO

116       This module is part of Log-Report distribution version 1.33, built on
117       July 17, 2021. Website: http://perl.overmeer.net/CPAN/
118

LICENSE

120       Copyrights 2007-2021 by [Mark Overmeer <markov@cpan.org>]. For other
121       contributors see ChangeLog.
122
123       This program is free software; you can redistribute it and/or modify it
124       under the same terms as Perl itself.  See http://dev.perl.org/licenses/
125
126
127
128perl v5.34.0                      2022-01-21         Log::Report::Exception(3)
Impressum