Home | Wiki | OI 1.x Docs | OI 2.x Docs OI logo

NAME

OpenInteract2::Exception - Base class for exceptions in OpenInteract

SYNOPSIS

 # Standard usage
 
 unless ( $user->check_password( $entered_password ) ) {
   OpenInteract2::Exception->throw( 'Bad login' );
 }
 
 # Pass a list of strings to form the message
 
 unless ( $user->check_password( $entered_password ) ) {
   OpenInteract2::Exception->throw( 'Bad login', $object->login_attempted )
 }
 
 # Using an exported shortcut
 
 use OpenInteract2::Exception qw( oi_error );
 oi_error "Bad login", $object->login_attempted;
 
 use OpenInteract2::Exception qw( oi_security_error );
 oi_security_error "Action failed due to security requirements",
                   { security_required => SEC_LEVEL_WRITE,
                     security_found    => SEC_LEVEL_READ };

DESCRIPTION

First, you should probably look at Exception::Class for more usage examples, why we use exceptions, what they are intended for, etc.

This is the base class for all OpenInteract exceptions. It declares a handful of exceptions and provides shortcuts to make raising an exception easier and more readable.

METHODS

throw( @msg, [ \%params ])

This overrides throw() from Exception::Class to add a little syntactic sugar. Instead of:

 $exception_class->throw( message => 'This is my very long error message that I would like to pass',
                          param1  => 'Param1 value',
                          param2  => 'Param2 value' );

You can use:

 $exception_class->throw( 'This is my very long error message ',
                          'that I would like to pass',
                          { param1 => 'Param1 value',
                            param2 => 'Param2 value' } );

And everything will work the same. Combined with the SHORTCUTS this makes for very readable code.

DECLARED EXCEPTION CLASSES

OpenInteract2::Exception::Application

Used for generic application errors.

Extra fields:

OpenInteract2::Exception::Datasource

Used for errors related to datasources.

Extra fields:

OpenInteract2::Exception::Parameter

Used for parameter validation errors, including if a parameter is not found.

Extra fields:

SHORTCUTS

You can import shortcuts for these methods

SEE ALSO

Exception::Class

OpenInteract2::Exception::Security

COPYRIGHT

Copyright (c) 2002-2003 Chris Winters. All rights reserved.

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

AUTHORS

Chris Winters <chris@cwinters.com>

Generated from the OpenInteract 1.99_03 source.


Home | Wiki | OI 1.x Docs | OI 2.x Docs
SourceForge Logo