1Params::CallbackRequestU:s:eErxcCeopnttiroinbsu(t3e)d PePralraDmosc:u:mCeanltlabtaicoknRequest::Exceptions(3)
2
3
4

NAME

6       Params::CallbackRequest::Exceptions - Parameter callback exception
7       definitions
8

SYNOPSIS

10         use Params::CallbackRequest::Exceptions;
11         Params::Callback::Exception::Execution->throw("Whoops!");
12
13         use Params::CallbackRequest::Exceptions abbr => [qw(throw_cb_exec)];
14         throw_cb_exec "Whoops!";
15

DESCRIPTION

17       This module creates the exceptions used by Params::CallbackRequest and
18       Params::Callback. The exceptions are subclasses of
19       Exception::Class::Base, created by the interface defined by
20       Exception::Class.
21

INTERFACE

23   Exported Functions
24       This module exports two functions by default.
25
26       "isa_cb_exception"
27
28         eval { something_that_dies() };
29         if (my $err = $@) {
30             if (isa_cb_exception($err, 'Abort')) {
31                 print "All hands abandon ship!";
32             } elsif (isa_cb_exception($err)) {
33                 print "I recall an exceptional fault.";
34             } else {
35                 print "No clue.";
36             }
37         }
38
39       This function takes a single argument and returns true if it's a
40       Params::Callback::Exception object. A second, optional argument can be
41       used to identify a particular subclass of Params::Callback::Exception.
42
43       "rethrow_exception"
44
45         eval { something_that_dies() };
46         if (my $err = $@) {
47             # Do something intelligent, and then...
48             rethrow_exception($err);
49         }
50
51       This function takes an exception as its sole argument and rethrows it.
52       If the argument is an object that "can('throw')", such as any subclass
53       of Exception::Class, then "rethrow_exception()" will call its rethrow
54       method. If not, but the argument is a reference, "rethrow_exception()"
55       will simply die with it. And finally, if the argument is not a
56       reference at all, "rethrow_exception()" will throw a new
57       Params::Callback::Exception exception with the argument used as the
58       exception error message.
59
60       Abbreviated Exception Functions
61
62       Each of the exception classes created by
63       Params::CallbackRequest::Exceptions has a functional alias for its
64       throw class method. These may be imported by passing an array reference
65       of the names of the abbreviated functions to import via the "abbr"
66       parameter:
67
68         use Params::CallbackRequest::Exceptions abbr => [qw(throw_cb_exec)];
69
70       The names of the abbreviated functions are:
71
72       throw_cb
73           Params::Callback::Exception
74
75       throw_bad_key
76           Params::Callback::Exception::InvalidKey
77
78       throw_cb_exec
79           Params::Callback::Exception::Execution
80
81       throw_bad_params
82           Params::Callback::Exception::Params
83
84       throw_abort
85           Params::Callback::Exception::Abort
86
87   Exception Classes
88       The exception classes created by Params::Callback::Exception are as
89       follows:
90
91       Params::Callback::Exception
92
93       This is the base class for all Params::Callback exception classes. Its
94       functional alias is "throw_cb".
95
96       Params::Callback::Exception::InvalidKey
97
98       Params::CallbackRequest throws this exception when a callback key in
99       the parameter hash passed to "new()" has no corresponding callback. In
100       addition to the attributes offered by Exception::Class::Base, this
101       class also features the attribute "callback_key". Use the
102       "callback_key()" accessor to see what callback key triggered the
103       exception. Params::Callback::Exception::InvalidKey's functional alias
104       is "throw_bad_key".
105
106       Params::Callback::Exception::Execution
107
108       This is the exception thrown by Params::CallbackRequest's default
109       exception handler when a callback subroutine or method dies. In
110       addition to the attributes offered by Exception::Class::Base, this
111       class also features the attributes "callback_key", which corresponds to
112       the parameter key that triggered the callback, and "callback_error"
113       which is the error thrown by the callback subroutine or method.
114       Params::Callback::Exception::Execution's functional alias is
115       "throw_cb_exec".
116
117       Params::Callback::Exception::Params
118
119       This is the exception thrown when an invalid parameter is passed to
120       Params::CallbackRequest's or Params::Callback's "new()" constructors.
121       Its functional alias is "throw_bad_params".
122
123       Params::Callback::Exception::Abort
124
125       This is the exception thrown by Params::Callback's "abort()" method.
126       functional alias is "throw_cb". In addition to the attributes offered
127       by Exception::Class::Base, this class also features the attribute
128       "aborted_value" attribute. Use the "aborted_value()" accessor to see
129       what value was passed to "abort()".
130       Params::Callback::Exception::Abort's functional alias is "throw_abort".
131

SEE ALSO

133       Params::Callback is the base class for all callback classes.
134
135       Params::CallbackRequest sets up callbacks for execution.
136
137       Exception::Class defines the interface for the exception classes
138       created here.
139

SUPPORT

141       This module is stored in an open GitHub repository
142       <http://github.com/theory/params-callbackrequest/>. Feel free to fork
143       and contribute!
144
145       Please file bug reports via GitHub Issues
146       <http://github.com/theory/params-callbackrequest/issues/> or by sending
147       mail to bug-params-callbackrequest@rt.cpan.org <mailto:bug-params-
148       callbackrequest@rt.cpan.org>.
149

AUTHOR

151       David E. Wheeler <david@justatheory.com>
152
154       Copyright 2003-2011 David E. Wheeler. Some Rights Reserved.
155
156       This library is free software; you can redistribute it and/or modify it
157       under the same terms as Perl itself.
158
159
160
161perl v5.32.0                      2020-07P-a2r8ams::CallbackRequest::Exceptions(3)
Impressum