Open Journal Systems
3.3.0
|
Public Member Functions | |
__construct ($package, $msgCallback=false, $contextCallback=false, $throwPEAR_Error=false) | |
_handleError ($err) | |
_log ($err) | |
getErrorMessageTemplate ($code) | |
getErrors ($purge=false, $level=false) | |
getMessageCallback () | |
hasErrors ($level=false) | |
pop () | |
popCallback () | |
push ($code, $level='error', $params=array(), $msg=false, $repackage=false, $backtrace=false) | |
pushCallback ($cb) | |
raiseError () | |
setContextCallback ($contextCallback) | |
setErrorMessageTemplate ($template) | |
setLogger (&$log) | |
setMessageCallback ($msgCallback) | |
Static Public Member Functions | |
static | _sortErrors ($a, $b) |
static | getErrorMessage (&$stack, $err, $template=false) |
static | getFileLine ($code, $params, $backtrace=null) |
static | setDefaultCallback ($callback=false, $package=false) |
static | setDefaultLogger (&$log) |
static & | singleton ( $package, $msgCallback=false, $contextCallback=false, $throwPEAR_Error=false, $stackClass='PEAR_ErrorStack') |
static | staticGetErrors ( $purge=false, $level=false, $merge=false, $sortfunc=array('PEAR_ErrorStack', '_sortErrors')) |
static | staticHasErrors ($package=false, $level=false) |
static | staticPop ($package) |
static | staticPopCallback () |
static | staticPush ( $package, $code, $level='error', $params=array(), $msg=false, $repackage=false, $backtrace=false) |
static | staticPushCallback ($cb) |
Data Fields | |
$_compat = false | |
$_contextCallback = false | |
$_errorCallback = array() | |
$_errorMsgs = array() | |
$_errors = array() | |
$_errorsByLevel = array() | |
$_logger = false | |
$_msgCallback = false | |
$_package | |
Definition at line 141 of file ErrorStack.php.
PEAR_ErrorStack::__construct | ( | $package, | |
$msgCallback = false , |
|||
$contextCallback = false , |
|||
$throwPEAR_Error = false |
|||
) |
Set up a new error stack
string | $package | name of the package this error stack represents |
callback | $msgCallback | callback used for error message generation |
callback | $contextCallback | callback used for context generation, defaults to getFileLine() |
boolean | $throwPEAR_Error |
Definition at line 258 of file ErrorStack.php.
References setContextCallback(), and setMessageCallback().
PEAR_ErrorStack::_handleError | ( | $err | ) |
Internal error handler for PEAR_ErrorStack class
Dies if the error is an exception (and would have died anyway) @access private
Definition at line 309 of file ErrorStack.php.
PEAR_ErrorStack::_log | ( | $err | ) |
Log an error using PEAR::Log
array | $err | Error array |
array | $levels | Error level => Log constant map @access protected |
Definition at line 651 of file ErrorStack.php.
References $_logger, and $GLOBALS.
Referenced by push().
|
static |
Error sorting function, sorts by time @access private
Definition at line 831 of file ErrorStack.php.
|
static |
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"
PEAR_ErrorStack | |
array | |
string|false | Pre-generated error message template |
Definition at line 930 of file ErrorStack.php.
References staticPush().
PEAR_ErrorStack::getErrorMessageTemplate | ( | $code | ) |
Standard Error Message Template generator from code
Definition at line 964 of file ErrorStack.php.
PEAR_ErrorStack::getErrors | ( | $purge = false , |
|
$level = false |
|||
) |
Retrieve all errors since last purge
boolean | set in order to empty the error stack |
string | level name, to return only errors of a particular severity |
Definition at line 737 of file ErrorStack.php.
References $_errors.
|
static |
Standard file/line number/function/class context callback
This function uses a backtrace generated from 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.
unused | |
integer | backtrace frame. |
array | Results of debug_backtrace() |
Definition at line 855 of file ErrorStack.php.
PEAR_ErrorStack::getMessageCallback | ( | ) |
Get an error code => error message mapping callback
This method returns the current callback that can be used to generate error messages
Definition at line 374 of file ErrorStack.php.
References $_msgCallback.
PEAR_ErrorStack::hasErrors | ( | $level = false | ) |
Determine whether there are any errors on the stack
string|array | Level name. Use to determine if any errors of level (string), or levels (array) have been pushed |
Definition at line 722 of file ErrorStack.php.
PEAR_ErrorStack::pop | ( | ) |
Pop an error off of the error stack
Definition at line 687 of file ErrorStack.php.
PEAR_ErrorStack::popCallback | ( | ) |
Remove a callback from the error callback stack
Definition at line 443 of file ErrorStack.php.
Referenced by push().
PEAR_ErrorStack::push | ( | $code, | |
$level = 'error' , |
|||
$params = array() , |
|||
$msg = false , |
|||
$repackage = false , |
|||
$backtrace = false |
|||
) |
Add an error to the stack
If the message generator exists, it is called with 2 parameters.
Next, if the error should contain context information, this is handled by the context grabbing method. Finally, the error is pushed onto the proper error stack
int | $code | Package-specific error code |
string | $level | Error level. This is NOT spell-checked |
array | $params | associative array of error parameters |
string | $msg | Error message, or a portion of it if the message is to be generated |
array | $repackage | If this error re-packages an error pushed by another package, place the array returned from pop() in this parameter |
array | $backtrace | Protected parameter: use this to pass in the debug_backtrace() that should be used to find error context |
array( 'code' => $code, 'params' => $params, 'package' => $this->_package, 'level' => $level, 'time' => time(), 'context' => $context, 'message' => $msg, //['repackage' => $err] repackaged error array/Exception class );
Normally, the previous array is returned.
Definition at line 520 of file ErrorStack.php.
References $_package, $GLOBALS, _log(), popCallback(), pushCallback(), raiseError(), staticPopCallback(), and staticPushCallback().
PEAR_ErrorStack::pushCallback | ( | $cb | ) |
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
string | array | $cb |
Definition at line 433 of file ErrorStack.php.
Referenced by push().
PEAR_ErrorStack::raiseError | ( | ) |
emulate PEAR::raiseError()
Definition at line 997 of file ErrorStack.php.
Referenced by push().
PEAR_ErrorStack::setContextCallback | ( | $contextCallback | ) |
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()
array|string|null | Callback function/method |
Definition at line 404 of file ErrorStack.php.
Referenced by __construct().
|
static |
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
array|string | Callback function/method |
string | Package name, or false for all packages |
Definition at line 387 of file ErrorStack.php.
References $GLOBALS.
|
static |
Set up a PEAR::Log object for all error stacks that don't have one
Log | $log |
Definition at line 327 of file ErrorStack.php.
References $GLOBALS.
PEAR_ErrorStack::setErrorMessageTemplate | ( | $template | ) |
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'
Definition at line 986 of file ErrorStack.php.
PEAR_ErrorStack::setLogger | ( | & | $log | ) |
Set up a PEAR::Log object for this error stack
Log | $log |
Definition at line 340 of file ErrorStack.php.
PEAR_ErrorStack::setMessageCallback | ( | $msgCallback | ) |
Set an error code => error message mapping callback
This method sets the callback that can be used to generate error messages for any instance
array|string | Callback function/method |
Definition at line 356 of file ErrorStack.php.
Referenced by __construct().
|
static |
Return a single error stack for this package.
Note that all parameters are ignored if the stack for package $package has already been instantiated
string | $package | name of the package this error stack represents |
callback | $msgCallback | callback used for error message generation |
callback | $contextCallback | callback used for context generation, defaults to getFileLine() |
boolean | $throwPEAR_Error | |
string | $stackClass | class to instantiate |
Definition at line 281 of file ErrorStack.php.
References $GLOBALS, and staticPush().
Referenced by staticPush().
|
static |
Get a list of all errors since last purge, organized by package
boolean | $purge | Set to purge the error stack of existing errors |
string | $level | Set to a level name in order to retrieve only errors of a particular level |
boolean | $merge | Set to return a flat array, not organized by package |
array | $sortfunc | Function used to sort a merged array - default sorts by time, and should be good for most cases |
Definition at line 803 of file ErrorStack.php.
References $GLOBALS.
|
static |
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
string|false | Package name to check for errors |
string | Level name to check for a particular severity |
Definition at line 776 of file ErrorStack.php.
References $GLOBALS.
|
static |
Pop an error off of the error stack, static method
string | package name |
Definition at line 706 of file ErrorStack.php.
References $GLOBALS.
|
static |
Remove a temporary overriding error callback
Definition at line 470 of file ErrorStack.php.
References $GLOBALS.
Referenced by push().
|
static |
Static version of push()
string | $package | Package name this error belongs to |
int | $code | Package-specific error code |
string | $level | Error level. This is NOT spell-checked |
array | $params | associative array of error parameters |
string | $msg | Error message, or a portion of it if the message is to be generated |
array | $repackage | If this error re-packages an error pushed by another package, place the array returned from pop() in this parameter |
array | $backtrace | Protected parameter: use this to pass in the debug_backtrace() that should be used to find error context |
Definition at line 630 of file ErrorStack.php.
References singleton().
Referenced by getErrorMessage(), and singleton().
|
static |
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)
string | array | $cb |
Definition at line 460 of file ErrorStack.php.
References $GLOBALS.
Referenced by push().
boolean PEAR_ErrorStack::$_compat = false |
Determines whether a PEAR_Error is thrown upon every error addition
@access private
Definition at line 186 of file ErrorStack.php.
false string array PEAR_ErrorStack::$_contextCallback = false |
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.
@access protected
Definition at line 212 of file ErrorStack.php.
false string array PEAR_ErrorStack::$_errorCallback = array() |
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
@access protected
Definition at line 227 of file ErrorStack.php.
array PEAR_ErrorStack::$_errorMsgs = array() |
array PEAR_ErrorStack::$_errors = array() |
Errors are stored in the order that they are pushed on the stack.
@access private
Definition at line 153 of file ErrorStack.php.
Referenced by getErrors().
array PEAR_ErrorStack::$_errorsByLevel = array() |
Storage of errors by level.
Allows easy retrieval and deletion of only errors from a particular level
@access private
Definition at line 166 of file ErrorStack.php.
false Log PEAR_ErrorStack::$_logger = false |
PEAR::Log object for logging errors
@access protected
Definition at line 237 of file ErrorStack.php.
Referenced by _log().
false string array PEAR_ErrorStack::$_msgCallback = false |
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
@access private
Definition at line 198 of file ErrorStack.php.
Referenced by getMessageCallback().
string PEAR_ErrorStack::$_package |
Package name this error stack represents
@access protected
Definition at line 176 of file ErrorStack.php.
Referenced by push().