Params...eptions(3pm)
β¨ NAME β¨
okay so welcome to Params::CallbackRequest::Exceptions β that's the Params...eptions(3pm) page, aka the User Contributed Perl Documentation for the exception definitions that Params::CallbackRequest and Params::Callback throw around. bestie, it's literally just the exception classes. that's the whole vibe. π
πΈ SYNOPSIS πΈ
use Params::CallbackRequest::Exceptions;
Params::Callback::Exception::Execution->throw("Whoops!");
use Params::CallbackRequest::Exceptions abbr => [qw(throw_cb_exec)];
throw_cb_exec "Whoops!";
look at that. two ways to say "Whoops!" and both of them slay. π
π¦ DESCRIPTION π¦
so this module is where the exceptions used by Params::CallbackRequest and Params::Callback get created. that's its whole job, no cap.
those exceptions are subclasses of Exception::Class::Base, and they're built with the interface defined by Exception::Class. iconic inheritance moment fr fr. β¨
π INTERFACE π
π«Ά Exported Functions
this module exports two functions by default. two. that's it. and they're both useful, so like, we stan.
isa_cb_exception
here's the whole vibe check:
eval { something_that_dies() };
if (my $err = $@) {
if (isa_cb_exception($err, 'Abort')) {
print "All hands abandon ship!";
} elsif (isa_cb_exception($err)) {
print "I recall an exceptional fault.";
} else {
print "No clue.";
}
}
so this function takes one argument and returns true if that thing is a Params::Callback::Exception object. that's it, that's the function. π
you can also slide in a second, optional argument to point at one specific subclass of Params::Callback::Exception β like, "is this the Abort kind specifically, bestie?" and it'll tell you yes or no. β
rethrow_exception
and here's the receipts:
eval { something_that_dies() };
if (my $err = $@) {
# Do something intelligent, and then...
rethrow_exception($err);
}
this one takes an exception as its sole argument and rethrows it. but the way it rethrows depends on what you handed it, and honestly the logic is giving tiered:
- if the argument is an object that
can('throw')β like, say, any subclass ofException::Classβ thenrethrow_exception()calls its rethrow method. easy. - if not that, but the argument is a reference, then
rethrow_exception()just plaindies with it. simple as. - and finally, if the argument isn't a reference at all,
rethrow_exception()throws a brand newParams::Callback::Exception, using the argument as the exception error message. π«Ά
π Abbreviated Exception Functions
every single exception class made by Params::CallbackRequest::Exceptions has a functional alias for its throw class method. short king behavior.
to get them, you import an array reference of the abbreviated function names you want, passed through the abbr parameter:
use Params::CallbackRequest::Exceptions abbr => [qw(throw_cb_exec)];
and here are the names of all the abbreviated functions, no gatekeeping:
throw_cbβParams::Callback::Exceptionthrow_bad_keyβParams::Callback::Exception::InvalidKeythrow_cb_execβParams::Callback::Exception::Executionthrow_bad_paramsβParams::Callback::Exception::Paramsthrow_abortβParams::Callback::Exception::Abort
π Exception Classes
the exception classes created by Params::Callback::Exception are as follows. get comfy, we're going through all of them:
Params::Callback::Exception
this is the base class for all the Params::Callback exception classes. its functional alias is throw_cb. the mother of the group chat, fr. π
Params::Callback::Exception::InvalidKey
Params::CallbackRequest throws this one when a callback key in the parameter hash passed to new() has no corresponding callback. like, you named a key and nothing answered. π
on top of all the attributes offered by Exception::Class::Base, this class also has the attribute callback_key. use the callback_key() accessor to find out which callback key triggered the exception. detective work, but make it perl. π΅οΈ
Params::Callback::Exception::InvalidKey's functional alias is throw_bad_key.
Params::Callback::Exception::Execution
this is the exception thrown by Params::CallbackRequest's default exception handler when a callback subroutine or method dies. dramatic? yes. deserved? also yes. π
on top of the attributes offered by Exception::Class::Base, this class also has two attributes:
callback_keyβ the parameter key that triggered the callbackcallback_errorβ the error thrown by the callback subroutine or method
Params::Callback::Exception::Execution's functional alias is throw_cb_exec.
Params::Callback::Exception::Params
thrown when an invalid parameter is passed to Params::CallbackRequest's or Params::Callback's new() constructors. it's the bouncer at the constructor door. π
its functional alias is throw_bad_params.
Params::Callback::Exception::Abort
thrown by Params::Callback's abort() method. the page also says, word for word, "functional alias is throw_cb" right there in this paragraph β yes, we noticed, and no, bestie, we are not editing it, we're just reporting what the doc says. π
on top of the attributes offered by Exception::Class::Base, this class also has the aborted_value attribute. use the aborted_value() accessor to see what value was passed to abort(). so you know exactly what got aborted. closure. π
Params::Callback::Exception::Abort's functional alias is throw_abort.
π SEE ALSO π
Params::Callbackis the base class for all callback classes.Params::CallbackRequestsets up callbacks for execution.Exception::Classdefines the interface for the exception classes created here.
three links, all essential, all linked into each other like the little ecosystem they are. iykyk. π
π SUPPORT π
this module is stored in an open GitHub repository at <http://github.com/theory/params-callbackrequest/>. feel free to fork and contribute! bestie, the door is open, come through. π«Ά
please file bug reports either via GitHub Issues at <http://github.com/theory/params-callbackrequest/issues/> or by sending mail to bug-params-callbackrequest@rt.cpan.org (that's <bug-params-callbackrequest@rt.cpan.org>). bugs deserve to be heard, periodt. π
β AUTHOR β
David E. Wheeler <david@justatheory.com> β thank you for your service, king. π
π COPYRIGHT AND LICENSE π
Copyright 2003-2011 David E. Wheeler. Some Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
so yeah β free software, some rights reserved, same terms as Perl itself. legal but make it cute. π
and that's the whole page, bestie!! this was Params...eptions(3pm), living under perl v5.36.0, dated 2022-10-15, in the fine tradition of User Contributed Perl Documentation. go forth and throw responsibly. mwah. πβ¨π¦πΈ
π¦ where this page comes from
- ubuntu noble: libparams-callbackrequest-perl 1.20-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libparams-callbackrequest-perl 1.20-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libparams-callbackrequest-perl 1.20-4 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms