Exception - Exception manager
use Exception;
try { throw( AnException->new() ) if $something; throw( AnOtherException->new( [] ) ) unless $anotherthing; } catch AnException( sub { } ) , onfly AnOtherException( sub { } ) ;
execute code until its end or an exception happens.
throw a list of exceptions.
create a new instance of an Exception.
execute an subroutine if this kind of exception is thrown
execute an subroutine and continue the execution of the last try if this kind of exception is thrown
add a flying exception handler. it allows to continue the try block where the exception appear.
return true if there is waitting exceptions, false elsewhere
create an object for catching methods. when a catch happens,
control if there is some exceptions to catch & treat in an stack
code for handling a exception. it's an empty sub actually. you overload it if you want a default handler for an exception.
the handler which intercept __WARN__ or __DIE__ signal
local %_XCPHDL_ = ( EXCEPTIONS => [], FLYS => [], STACKFLY => [], ONFLY => 0, FRESH => 0, CANDIE => 0 );
@{$Exception::_XCPHDL_->{EXCEPTIONS}} is the stack of thrown exceptions.
@{$Exception::_XCPHDL_->{FLYS}} is the stack of fly exception handler.
@{$Exception::_XCPHDL_->{STACKFLY}} contain a stack of the list of onfly exception. each list is linked to a nested try.
it's a flag which determine if an handler can die when it throws.
is up only when fresh exception are thrown.
is up when a die call must be done.
a try block is a code block which is evaluated.
when you throw a new set of exception, this set is pushed in @{$Exception::_XCPHDL_->{EXCEPTIONS}} , the system call die.
then $SIG{__DIE__} check if any waitting may be catched, when it finish and there is waitting exception yet, it die, else it continues the try block ; it's the onfly exception handling.
the catching part is the same thing than upside, but you can't continue the execution of the try block.
Don't try to change $SIG{__WARN__} and $SIG{__DIE__} inside a try block.
this module is under the LGPL. you can download this module at http://XVII-ToolBox.sourceforge.net/XVII-ToolBox.tgz
Samuel Mouniée aka Moun's, mouns@users.sourceforge.net
perl(1).