BPM::Engine::Exceptions - Exception classes used in BPM::Engine




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) ) {
        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:

    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.


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.

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:

  • BPM::Engine::Exception

    This is the base class for all generated exceptions.

  • BPM::Engine::Exception::Engine

    Engine exception. Aliased as throw_engine.

  • BPM::Engine::Exception::Runner

    ProcessRunner exception. Aliased as throw_runner.

  • BPM::Engine::Exception::Database

    Datastore exception. Aliased as throw_store.

  • BPM::Engine::Exception::IO

    IO exception. Aliased as throw_io.

  • BPM::Engine::Exception::Parameter

    Invalid parameters was given to method/function. Aliased as throw_param.

  • BPM::Engine::Exception::Condition

    Condition false error. Aliased as throw_condition.

  • BPM::Engine::Exception::Expression

    Exception evaluator error. Aliased as throw_expression.

  • BPM::Engine::Exception::Plugin

    Plugin exception. Extra field: plugin. Aliased as throw_plugin.

  • BPM::Engine::Exception::Model

    Model exception. Aliased as throw_model.

  • BPM::Engine::Exception::Install

    Installation/configuration exception. Aliased as throw_install.

  • BPM::Engine::Exception::NotImplemented

    Abstract method. Aliased as throw_abstract.



Peter de Vos <>


Copyright (c) 2010, 2011 Peter de Vos <>.

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