Error Stack Implementation
Usage:
- // global error stack
- $global_stack = &PEAR_ErrorStack::singleton('MyPackage');
- // local error stack
- $local_stack = new PEAR_ErrorStack('MyPackage');
Located in /maintenance/libraries/pear/PEAR/ErrorStack.php (line 152)
Determines whether a PEAR_Error is thrown upon every error addition
If set to a valid callback, this will be used to generate the error
context for an error. For PHP-related errors, this will be a file and line number as retrieved from debug_backtrace(), but can be customized for other purposes. The error might actually be in a separate configuration file, or in a database query.
If set to a valid callback, this will be called every time an error is pushed onto the stack. The return value will be used to determine whether to allow an error to be pushed or logged.
The return value must be one an PEAR_ERRORSTACK_* constant
Error messages - designed to be overridden
Errors are stored in the order that they are pushed on the stack.
Storage of errors by level.
Allows easy retrieval and deletion of only errors from a particular level
PEAR::Log object for logging errors
If set to a valid callback, this will be used to generate the error
message from the error code, otherwise the message passed in will be used
Package name this error stack represents
Set up a new error stack
Standard error message generation callback
This method may also be called by a custom error message generator to fill in template values from the params array, simply set the third parameter to the error message template string to use
The special variable %__msg% is reserved: use it only to specify where a message passed in by the user should be placed in the template, like so:
Error message: %msg% - internal error
If the message passed like so:
- $stack->push(ERROR_CODE, 'error', array(), 'server error 500');
The returned error message will be "Error message: server error 500 - internal error"
Standard Error Message Template generator from code
Retrieve all errors since last purge
Standard file/line number/function/class context callback
This function uses a backtrace generated from http://www.php.net/debug_backtrace and so will not work at all in PHP < 4.3.0. The frame should reference the frame that contains the source of the error.
Get an error code => error message mapping callback
This method returns the current callback that can be used to generate error messages
Determine whether there are any errors on the stack
Pop an error off of the error stack
Remove a callback from the error callback stack
Add an error to the stack
If the message generator exists, it is called with 2 parameters.
Set an error Callback If set to a valid callback, this will be called every time an error is pushed onto the stack. The return value will be used to determine whether to allow an error to be pushed or logged.
The return value must be one of the ERRORSTACK_* constants.
This functionality can be used to emulate PEAR's pushErrorHandling, and the PEAR_ERROR_CALLBACK mode, without affecting the integrity of the error stack or logging
Set a callback that generates context information (location of error) for an error stack
This method sets the callback that can be used to generate context information for an error. Passing in NULL will disable context generation and remove the expensive call to debug_backtrace()
Sets a default callback to be used by all error stacks
This method sets the callback that can be used to generate error messages for a singleton
Set up a PEAR::Log object for all error stacks that don't have one
Set the Error Message Template array
The array format must be:
array(error code => 'message template',...)
Error message parameters passed into push() will be used as input for the error message. If the template is 'message %foo% was %bar%', and the parameters are array('foo' => 'one', 'bar' => 'six'), the error message returned will be 'message one was six'
Set an error code => error message mapping callback
This method sets the callback that can be used to generate error messages for any instance
Return a single error stack for this package.
Note that all parameters are ignored if the stack for package $package has already been instantiated
Get a list of all errors since last purge, organized by package
Determine whether there are any errors on a single error stack, or on any error stack
The optional parameter can be used to test the existence of any errors without the need of singleton instantiation
Remove a temporary overriding error callback
Static version of push()
Set a temporary overriding error callback for every package error stack
Use this to temporarily disable all existing callbacks (can be used to emulate the @ operator, for instance)
Internal error handler for PEAR_ErrorStack class
Dies if the error is an exception (and would have died anyway)
Log an error using PEAR::Log
Error sorting function, sorts by time
Documentation generated on Fri, 11 Feb 2005 18:13:03 +0000 by phpDocumentor 1.3.0RC3