man Params::CallbackRequest::Exceptions () - Parameter callback exception definitions

NAME

Params::CallbackRequest::Exceptions - Parameter callback exception definitions

SYNOPSIS

  use Params::CallbackRequest::Exceptions;
  Params::Callback::Exception::Execution->throw("Whoops!");

  use Params::CallbackRequest::Exceptions abbr => [qw(throw_cb_exec)];
  throw_cb_exec "Whoops!";

DESCRIPTION

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

INTERFACE

Exported Functions

This module exports two functions by default.

CIisa_cb_exception

  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.";
      }
  }

This function takes a single argument and returns true if it's a Params::Callback::Exception object. A second, optional argument can be used to identify a particular subclass of Params::Callback::Exception.

CIrethrow_exception

  eval { something_that_dies() };
  if (my $err = $@) {
      # Do something intelligent, and then...
      rethrow_exception($err);
  }

This function takes an exception as its sole argument and rethrows it. If the argument is an object that CWcan('throw'), such as any subclass of Exception::Class, then CWrethrow_exception() will call its rethrow method. If not, but the argument is a reference, CWrethrow_exception() will simply die with it. And finally, if the argument is not a reference at all, CWrethrow_exception() will throw a new Params::Callback::Exception exception with the argument used as the exception error message.

Abbreviated Exception Functions

Each of the exception classes created by Params::CallbackRequest::Exceptions has a functional alias for its throw class method. These may be imported by passing an array reference of the names of the abbreviated functions to import via the CWabbr parameter:

  use Params::CallbackRequest::Exceptions abbr => [qw(throw_cb_exec)];

The names of the abbreviated functions are:

throw_cb
Params::Callback::Exception
throw_bad_key
Params::Callback::Exception::InvalidKey
throw_cb_exec
Params::Callback::Exception::Execution
throw_bad_params
Params::Callback::Exception::Params
throw_abort
Params::Callback::Exception::Abort

Exception Classes

The exception classes created by Params::Callback::Exception are as follows:

Params::Callback::Exception

This is the base class for all Params::Callback exception classes. Its functional alias is CWthrow_cb.

Params::Callback::Exception::InvalidKey

Params::CallbackRequest throws this exception when a callback key in the parameter hash passed to CWnew() has no corresponding callback. In addition to the attributes offered by Exception::Class::Base, this class also features the attribute CWcallback_key. Use the CWcallback_key() accessor to see what callback key triggered the exception. Params::Callback::Exception::InvalidKey's functional alias is CWthrow_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. In addition to the attributes offered by Exception::Class::Base, this class also features the attributes CWcallback_key, which corresponds to the parameter key that triggered the callback, and CWcallback_error which is the error thrown by the callback subroutine or method. Params::Callback::Exception::Execution's functional alias is CWthrow_cb_exec.

Params::Callback::Exception::Params

This is the exception thrown when an invalid parameter is passed to Params::CallbackRequest's or Params::Callback's CWnew() constructors. Its functional alias is CWthrow_bad_params.

Params::Callback::Exception::Abort

This is the exception thrown by Params::Callback's CWabort() method. functional alias is CWthrow_cb. In addition to the attributes offered by Exception::Class::Base, this class also features the attribute CWaborted_value attribute. Use the CWaborted_value() accessor to see what value was passed to CWabort(). Params::Callback::Exception::Abort's functional alias is CWthrow_abort.

SEE ALSO

Params::Callback is the base class for all callback classes.

Params::CallbackRequest sets up callbacks for execution.

Exception::Class defines the interface for the exception classes created here.

AUTHOR

David Wheeler <david@kineticode.com>

COPYRIGHT AND LICENSE

Copyright 2003 by David Wheeler

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.