The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

OpenInteract::Error::Main - Catches all errors and dispatches to proper handler

SYNOPSIS

 $R->throw( { code => 412, type => 'db' } );

DESCRIPTION

This class catches all errors thrown by the framework. It then inspects the error, reviews the current context and decides which class and method should handle the error.

To do this, it needs to be able to determine a few things:

  • What type of error is this? The code (and possibly type) found in the error passed to catch() should be sufficient to distinguish errors from one another.

  • From where was the error thrown? This is a crucial piece of information, because it determines which set of error handlers we inspect. We get this information from $R in the {current_context} key. This key is either set by hand, or set when we call the lookup_action() method of $R.

The main method, catch(), determines the context in which the error was thrown. (This should be simple: just ask $R.) It then determines which error handler(s) should be queried as to whether it/they can deal with the error thrown.

The last entry in the list of error handlers should always be the default system catalog of error handlers. They may be generic, but they can catch any error and return something more meaningful than 'Internal Systen Error.'

METHODS

catch( $err )

Discussed above.

initialize( { config = $C } )>

Should be called from the Apache child init handler. In your startup file, be sure to add something like this:

 Apache->push_handlers( PerlChildInitHandler => sub {
   ...blah blah blah...

   OpenInteract::Error::Main->initialize( { config => $C } );

   ...blah blah blah...
  }
 )

This initializes the class with information from all the packages, including the handlers they intend to use for their errors.

TO DO

Nothing.

BUGS

None known.

COPYRIGHT

Copyright (c) 2001-2002 intes.net, inc.. 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>