NAME
App::Framework::Base::Object::ErrorHandle - Adds error handling to basic object
SYNOPSIS
use App::Framework::Base::Object::ErrorHandle ;
DESCRIPTION
Any object derived from this class can throw an error and some registered error handler will catch (and handle) that error.
Hierarchy of catch handlers is:
catch_fn set for this object instance
any registered global catch function (last registered first)
default handler
Global catch functions, when registered, are added to a stack so that the last one registered is called first.
Each handler must return either 1=handled, or 0=not handled to tell this object whether to move on to the next handler.
NOTE: The default handler may be over-ridden by any derived object.
This object is set up such that when used as stand-alone objects (i.e. outside of an application framework), then errors are handled with die(), warn() etc.
DIAGNOSTICS
Setting the debug flag to level 1 prints out (to STDOUT) some debug messages, setting it to level 2 prints out more verbose messages.
AUTHOR
Steve Price <sdprice at cpan.org>
BUGS
None that I know of!
INTERFACE
- new([%args])
-
Create a new App::Framework::Base::Object::ErrorHandle.
The %args are specified as they would be in the set method, for example:
'mmap_handler' => $mmap_handler
The full list of possible arguments are :
'fields' => Either ARRAY list of valid field names, or HASH of field names with default values
- init_class([%args])
-
Initialises the App::Framework::Base::Object::ErrorHandle object class variables. Creates a class instance so that these methods can also be called via the class (don't need a specific instance)
- add_global_error($error)
-
Add a new error to the Class list keeping track of all runtime errors
- global_error([%args])
-
Add a new error to the Class list keeping track of all runtime errors
%args hash contains:
* type = fatal, nonfatal, warning, note * message = text message * errorcode = integer error code value
- global_last_error()
-
Returns a hash containing the information from the last error stored in the global list
Hash contains:
* type = fatal, nonfatal, warning, note * message = text message * errorcode = integer error code value
If there are no errors, returns undef
- global_errors()
-
Returns the list of all errors
- any_error()
-
Returns a hash containing the information from the last actual error (i.e. only 'fatal' or 'nonfatal' types) stored in the global list
Hash contains:
* type = fatal, error, warning, note * message = text message * errorcode = integer error code value
If there are no errors, returns undef
- error_check($error, $mask)
-
Returns TRUE if the $error object type matches the mask
- is_error($error)
-
Returns TRUE if the $error object is either 'fatal' or 'nonfatal'
- is_warning($error)
-
Returns TRUE if the $error object is 'warning'
- is_note($error)
-
Returns TRUE if the $error object is 'note'
- error_split($error)
-
Split the error object into component parts and return them in an ARRAY:
[0] = Message [1] = Error code [2] = Type [3] = Parent
- register_global_handler($code_ref)
-
Add a new global error handler on to the stack
- default_error_handler($error)
-
Last ditch attempt to handle errors. Uses die(), warn() etc as appropriate.
- _throw_error($error)
-
Add a new error to this object instance, also adds the error to this Class list keeping track of all runtime errors
- rethrow_error($error_ref)
-
Throws an error for this object based on an error object associated with a different object
- throw_error([%args])
-
Add a new error to this object instance, also adds the error to this Class list keeping track of all runtime errors
%args hash contains:
* type = fatal, nonfatal, warning, note * message = text message * errorcode = integer error code value
- throw_fatal($message, [$errorcode])
-
Add a new error (type=fatal) to this object instance, also adds the error to this Class list keeping track of all runtime errors
- throw_nonfatal($message, [$errorcode])
-
Add a new error (type=nonfatal) to this object instance, also adds the error to this Class list keeping track of all runtime errors
- throw_warning($message, [$errorcode])
-
Add a new error (type=warning) to this object instance, also adds the error to this Class list keeping track of all runtime errors
- throw_note($message, [$errorcode])
-
Add a new error (type=note) to this object instance, also adds the error to this Class list keeping track of all runtime errors
- last_error()
-
Returns a hash containing the information from the last (worst case) error stored for this object i.e. if a 'fatal' error is followed by some 'note's then the 'fatal' error is returned
Hash contains:
* type = fatal, error, warning, note * message = text message * errorcode = integer error code value
If there are no errors, returns undef
- error()
-
Returns a hash containing the information from the last actual error (i.e. only 'fatal' or 'nonfatal' types) stored for this object
Hash contains:
* type = fatal, error, warning, note * message = text message * errorcode = integer error code value
If there are no errors, returns undef
- _create_error()
-
Returns a hash containing the information from the last error stored for this object
Hash contains:
* type = fatal, error, warning, note * message = text message * errorcode = integer error code value
If there are no errors, returns undef
- _cmp_error($err1, $err2)
-
Compares error types. If the type of $err1 is more srious than $err2 then returns positive; if type $err1 is less serious than $err2 then returns negative; otherwise returns 0
Order of seriousness:
* fatal * error * warning * note
- _latest_worst_error($errors_aref)
-
Works through the specified errors list and returns the latest, worst error