\patErrorManager

patErrorManager main error management class used by pat tools for the application-internal error management. Creates patError objects for any errors for precise error management.

Summary

Methods
Properties
Constants
isError()
raiseError()
raiseWarning()
raiseNotice()
raise()
registerErrorLevel()
setErrorHandling()
getErrorHandling()
translateErrorLevel()
setErrorClass()
addIgnore()
removeIgnore()
getIgnore()
clearIgnore()
pushExpect()
popExpect()
getExpect()
clearExpect()
handleErrorIgnore()
handleErrorEcho()
handleErrorVerbose()
handleErrorDie()
handleErrorTrigger()
handleErrorCallback()
handleErrorException()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

isError()

isError(  $object) : boolean

method for checking whether the return value of a pat application method is a pat error object.

Parameters

$object

Returns

boolean —

$result True if argument is a patError-object, false otherwise.

raiseError()

raiseError(string  $code, string  $msg, mixed  $info = null) : object

wrapper for the {@link raise()} method where you do not have to specify the error level - a {@link patError} object with error level E_ERROR will be returned.

Parameters

string $code

The application-internal error code for this error

string $msg

The error message, which may also be shown the user if need be.

mixed $info

Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).

Returns

object —

$error The configured patError object

raiseWarning()

raiseWarning(string  $code, string  $msg, mixed  $info = null) : object

wrapper for the {@link raise()} method where you do not have to specify the error level - a {@link patError} object with error level E_WARNING will be returned.

Parameters

string $code

The application-internal error code for this error

string $msg

The error message, which may also be shown the user if need be.

mixed $info

Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).

Returns

object —

$error The configured patError object

raiseNotice()

raiseNotice(string  $code, string  $msg, mixed  $info = null) : object

wrapper for the {@link raise()} method where you do not have to specify the error level - a {@link patError} object with error level E_NOTICE will be returned.

Parameters

string $code

The application-internal error code for this error

string $msg

The error message, which may also be shown the user if need be.

mixed $info

Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).

Returns

object —

$error The configured patError object

raise()

raise(integer  $level, string  $code, string  $msg, mixed  $info = null) : mixed

creates a new patError object given the specified information.

Parameters

integer $level

The error level - use any of PHP's own error levels for this: E_ERROR, E_WARNING, E_NOTICE, E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE.

string $code

The application-internal error code for this error

string $msg

The error message, which may also be shown the user if need be.

mixed $info

Optional: Additional error information (usually only developer-relevant information that the user should never see, like a database DSN).

Returns

mixed —

$error The configured patError object or false if this error should be ignored

registerErrorLevel()

registerErrorLevel(  $level,   $name) : boolean

register a new error level

This allows you to add custom error levels to the built-in

  • E_NOTICE
  • E_WARNING
  • E_NOTICE

You may use this level in subsequent calls to raise(). Error handling will be set to 'ignore' for the new level, you may change it by using setErrorHandling().

You could be using PHP's predefined constants for error levels or any other integer value.

Parameters

$level
$name

Returns

boolean —

true on success; false if the level already has been registered

setErrorHandling()

setErrorHandling(integer  $level, string  $mode, mixed  $options = null) : mixed

sets the way the patErrorManager will handle teh different error levels. Use this if you want to override the default settings.

Error handling modes:

  • ignore
  • trigger
  • verbose
  • echo
  • callback
  • die

You may also set the error handling for several modes at once using PHP's bit operations. Examples:

  • E_ALL = Set the handling for all levels
  • E_ERROR | E_WARNING = Set the handling for errors and warnings
  • E_ALL ^ E_ERROR = Set the handling for all levels except errors

Parameters

integer $level

The error level for which to set the error handling

string $mode

The mode to use for the error handling.

mixed $options

Optional: Any options needed for the given mode.

Returns

mixed —

$result True on success, or a patError object if failed.

getErrorHandling()

getErrorHandling(integer  $level) : array

retrieves the current error handling settings for the specified error level.

Parameters

integer $level

The error level to retrieve. This can be any of PHP's own error levels, e.g. E_ALL, E_NOTICE...

Returns

array —

$handling All error handling details

translateErrorLevel()

translateErrorLevel(  $level) : string

translate an error level

returns the human-readable name for an error level, e.g. E_ERROR will be translated to 'Error'.

Parameters

$level

Returns

string —

human-readable representation

setErrorClass()

setErrorClass(string  $name) : boolean

setErrorClass

In order to autoload this class, the filename containing that class must be named like the class itself; with an appending ".php". Although the file must be stored in the same directory as patErrorManager.php (this file)

Parameters

string $name

classname

Returns

boolean —

$result true on success

addIgnore()

addIgnore(mixed  $codes) : boolean

add error codes to be ingored

Parameters

mixed $codes

either an array of error code or a single code that will be ignored in future

Returns

boolean —

$result true on success

removeIgnore()

removeIgnore(  $codes) : boolean

removeIgnore

Parameters

$codes

Returns

boolean —

$result true on success

getIgnore()

getIgnore() : array

recieve all registerd error codes that will be ignored

Returns

array —

$codes list of error codes

clearIgnore()

clearIgnore() : boolean

empty list of errors to be ignored

Returns

boolean —

$result true on success

pushExpect()

pushExpect(mixed  $codes) : boolean

add expected errors to stack

Parameters

mixed $codes

either an array of error code or a single code that will be ignored in future

Returns

boolean —

$result true on success

popExpect()

popExpect() : boolean

remove top of error-codes from stack

Returns

boolean —

$result true on success

getExpect()

getExpect() : array

recieve all registerd error codes that will be ignored

Returns

array —

$codes list of error codes

clearExpect()

clearExpect() : boolean

empty list of errors to be ignored

Returns

boolean —

$result true on success

handleErrorIgnore()

handleErrorIgnore(object  $error, array  $options) : object

handleError: Ignore Does nothing

Parameters

object $error

patError-Object

array $options

options for handler

Returns

object —

$error error-object

handleErrorEcho()

handleErrorEcho(object  $error, array  $options) : object

handleError: Echo display error message

Parameters

object $error

patError-Object

array $options

options for handler

Returns

object —

$error error-object

handleErrorVerbose()

handleErrorVerbose(object  $error, array  $options) : object

handleError: Verbose display verbose output for developing purpose

Parameters

object $error

patError-Object

array $options

options for handler

Returns

object —

$error error-object

handleErrorDie()

handleErrorDie(object  $error, array  $options) : object

handleError: die display error-message and die

Parameters

object $error

patError-Object

array $options

options for handler

Returns

object —

$error error-object

handleErrorTrigger()

handleErrorTrigger(object  $error, array  $options) : object

handleError: trigger trigger php-error

Parameters

object $error

patError-Object

array $options

options for handler

Returns

object —

$error error-object

handleErrorCallback()

handleErrorCallback(object  $error, array  $options) : object

handleError: callback forward error to custom handler

Parameters

object $error

patError-Object

array $options

options for handler

Returns

object —

$error error-object

handleErrorException()

handleErrorException(object  $error, array  $options) : null

handleError: throw an exception

Parameters

object $error

patError-Object

array $options

options for handler

Throws

\Exception

Returns

null