Class Fault
Global error handling system for triggered errors and uncaught exceptions.
Handles triggered errors and uncaught exceptions, including fatal errors via a special shutdown handler. Each incident is reported via all configured reporters, defaulting to the 'stdout:' reporter. If all reporters fail, an integrated basic formatter will print out incident details to the standard output in either plain text for CLI applications or otherwise HTML.
Own error handling can be implemented by deriving an own fault handler from this class.
To identify a request, the fault instance UUID is generally used. This is useful to connect multiple reports together, or to present an identifier for a reported problem to the user.
- Core\Object implements Core\Chainable
- Core\Set implements Core\Accessor
- Core\Fault implements Core\Chainable
Package: Core
Since: 3.0
Requires: PHP 5.3
Version: 2.0
Used by:
xc_dump_bt()
Located at Fault.inc.php
Methods summary
public static
|
#
instance( )
Returns the singleton instance. The fault handler can be configured
using the |
protected
|
|
protected
|
#
_format(
Formats and prints out an incident in case reporter drivers failed or an error occurred during handling an incident. No character sets are used, the output is simplified (i.e. no call arguments are being rendered) and only uses minimal HTML formatting in case no CLI app is being detected. |
protected
string
|
#
_formatMessage( $message )
Formats a message for direct output. The text is returned with a newline appended for CLI applications, otherwise formatted and encoded in HTML. Takes advantage of an already existing fault CSS. |
protected
boolean
|
#
_handle(
Prints out error and stops script execution if error is fatal or error threshold was reached. |
public
integer|boolean
|
#
chain(
Connects another object to the current object. Usage depends on the actual class implementation; common examples are lazy configuration completion or layer expansions. Allows setting additional reporter instances or replacing the current set of reporters. Alternatively, reporters can be added by directly appending a new reporter instance to the reporters property. |
public
boolean
|
#
handleError( integer $errorCode, string $message = null, string $filename = null, integer $line = null, mixed $context = null, boolean $silentError = null )
Handler for triggered errors. |
public
|
|
public
|
|
public
integer
|
#
levelThreshold( )
Returns the configured threshold for the maximum incident level after which execution is stopped to avoid recursion in error handling. The value if always read from the configured configuration instance and can be changed during runtime by adjusting the configuration accordingly. |
public
string
|
#
reference( )
Returns the request reference identifier commonly used to connect reports together or give users a reference number on error pages. |
public
integer
|
#
threshold( )
Returns the configured threshold for incidents after which execution is stopped when the number of handled recoverable incidents exceeds the configured threshold. The value if always read from the configured configuration instance and can be changed during runtime by adjusting the configuration accordingly. |
public
array[]
|
Methods inherited from Core\Object
__autocreateFactory()
,
__call()
,
__processParameters()
,
__toString()
,
attachMethod()
,
getValueForKey()
,
getValueForKeyPath()
,
getValueForUndefinedKey()
,
hash()
,
issetValueForKey()
,
setValueForKey()
,
setValueForKeyPath()
,
setValueForUndefinedKey()
,
uuid()
Constants summary
integer |
DefaultThreshold
Default incidents threshold used if not defined in system configuration. |
#
5
|
integer |
DefaultLevelThreshold
Default level threshold for incidents if not defined in system configuration to avoid recursively appearing incidents. |
#
2
|
string |
DefaultFaultClass
Name of default fault handler class. Used, if either no fault handler class is found in the system configuration, or an exception occurred while parsing the system configuration. |
#
'core.fault'
|
string |
UnknownSourceLabel
Replacement string used for unknown sources, i.e. missing filenames in incidents and traces. |
#
'<unknown source>'
|
Constants inherited from Core\Object
AnyParameterType
,
AutochainParameterType
,
AutocreateParameterType
,
BooleanParameterType
,
CharParameterType
,
EnumParameterType
,
IntegerParameterType
,
RealParameterType
,
StringParameterType
,
UserParameterType
Properties summary
protected
integer
|
$_v_incidentLevel
Current incident processing level. If >0, then an incident is currently being processed by the fault handler. If >1, an incident was raised during the execution of the fault handler. |
#
0
|
protected
integer
|
$_v_incidents
Number of encountered incidents since start of script execution. |
#
0
|
protected
string| |
$_v_referenceFormat
Request reference identifier format or encoder instance, depending on configuration. |
|
protected
integer
|
$_v_referenceLength
Request reference identifier length in bits. If negative, the reference is based on the given number of bits from the end of the UUID. |
|
protected
|
$_v_reporters
Array object of registered reporter instances. |
|
protected static
|
$_instance
Singleton instance. |
Magic properties
public read-only
integer
|
$incidentLevel
Current incident processing level. |
public read-only
integer
|
$incidents
Number of encountered incidents since start of script execution. |
public read-only
integer
|
$levelThreshold
Configured incident level threshold value. |
public read-only
string
|
$reference
Formatted request reference identifier. |
public read-only
string| |
$referenceFormat
Configured transformation for request reference identifiers. Can be an encoder instance, depending on configuration. |
public read-only
integer
|
$referenceLength
Length in bits of request reference identifiers. If negative, the reference is based on the given number of bits from the end of the UUID. |
public read-only
integer
|
$threshold
Configured incidents threshold value. |
public read-only
array
|
$trace
Retrieves the current call trace (including KVC property access calls). |