BPM::Engine::Exceptions - Exception classes used in BPM::Engine
0.01
Throw an exception when something is wrong
use BPM::Engine::Exceptions qw/throw_plugin/; sub set_length { my ($self, $length) = @_; # throw an exception throw_plugin("Whoops!") unless $length =~ /\d+/; # ... }
Now let's try something illegal and catch the exception
# use the is_Exception() function exported from the types library use BPM::Engine::Types qw/Exception/; eval { $obj->set_length( 'non-numerical value' ); # this throws the error #... }; # handle any exception, cathing them in various ways if(my $err = $@) { # encountered an error if( Exception::Class->caught('BPM::Engine::Exception::Engine') ) { #... use the thrown error obj warn $err->error; print $err->as_html; } elsif(my $err = BPM::Engine::Exception::Plugin->caught() ) { warn $err->trace->as_string; } # the type tests blessed $@ && $@->isa('BPM::Engine::Exception') elsif( is_Exception($err) ) { $err->rethrow(); } else { # something bad happened! die $@; } }
BPM::Engine::Exception stringifies to something reasonable, so if you don't need detailed error information, you can simply treat $@ as a string:
BPM::Engine::Exception
eval { $engine->update($status) }; if ( $@ ) { warn "update failed because: $@\n"; }
This module creates the hierarchy of exception objects used by other BPM::Engine modules and provides shortcuts to make raising an exception easier and more readable.
The exceptions are subclasses of Exception::Class::Base, created by the interface defined by Exception::Class. See Exception::Class for more information on how this is done.
Exception::Class
Each of the exception classes created by BPM::Engine::Exceptions has a functional alias for its throw class method. In the SYNOPSIS example, we use the throw_plugin function to throw a BPM::Engine::Exception::Plugin exception.
throw_plugin
BPM::Engine::Exception::Plugin
These may be imported by passing a list of the function names to import:
use BPM::Engine::Exceptions qw(throw_component);
Some of the exceptions mentioned above have additional fields, which are available via accessors.
The exception classes created by BPM::Engine::Exceptions are as follows:
This is the base class for all generated exceptions.
BPM::Engine::Exception::Engine
Engine exception. Aliased as throw_engine.
throw_engine
BPM::Engine::Exception::Runner
ProcessRunner exception. Aliased as throw_runner.
throw_runner
BPM::Engine::Exception::Database
Datastore exception. Aliased as throw_store.
throw_store
BPM::Engine::Exception::IO
IO exception. Aliased as throw_io.
throw_io
BPM::Engine::Exception::Parameter
Invalid parameters was given to method/function. Aliased as throw_param.
throw_param
BPM::Engine::Exception::Condition
Condition false error. Aliased as throw_condition.
throw_condition
BPM::Engine::Exception::Expression
Exception evaluator error. Aliased as throw_expression.
throw_expression
Plugin exception. Extra field: plugin. Aliased as throw_plugin.
plugin
BPM::Engine::Exception::Model
Model exception. Aliased as throw_model.
throw_model
BPM::Engine::Exception::Install
Installation/configuration exception. Aliased as throw_install.
throw_install
BPM::Engine::Exception::NotImplemented
Abstract method. Aliased as throw_abstract.
throw_abstract
Peter de Vos <sitetech@cpan.org>
Copyright (c) 2010, 2011 Peter de Vos <sitetech@cpan.org>.
<sitetech@cpan.org>
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
To install BPM::Engine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm BPM::Engine
CPAN shell
perl -MCPAN -e shell install BPM::Engine
For more information on module installation, please visit the detailed CPAN module installation guide.