Class for error handling.
| Properties | |
|---|---|
|
static
protected
|
Internal variable for storing the last error. |
|
protected
|
Internal variable for storing the log path. |
|
static
protected
|
Internal variable for storing the state of tracing - active or not. |
| Methods | |
|---|---|
|
protected
|
This is an auxiliary function for generation of the detailed string from the function arguments from the standard PHP backtrace (debug_backtrace). |
|
public
|
Disables the trace. |
|
public
|
Enables the trace. |
|
protected
|
Extracts the call stack from the standard PHP backtrace (debug_backtrace). |
|
public
|
Formats the standard PHP backtrace (debug_backtrace). |
|
public
|
Returns the last error. |
|
public
|
This is the function for handling of the PHP errors. It is set in the error handler. |
|
public
|
This is the function for handling of the PHP exceptions. It should be called in the catch block to trace detailed information if an exception is thrown. |
|
public
|
Initializes the error handler with parameters. |
|
protected
|
Generates the detailed string from the function arguments from the standard PHP backtrace (debug_backtrace). |
|
public
|
Stores the last error. |
|
public
|
Returns the state whether the trace is active or not. |
|
protected
|
Traces an error to the standard trace file (logs/trace.log). |
|
protected
|
This is an auxiliary function that cuts off the common part of the path. |
|
protected
|
This is an auxiliary function for truncating long arguments. |
Internal variable for storing the last error.
Internal variable for storing the log path.
Internal variable for storing the state of tracing - active or not.
This is an auxiliary function for generation of the detailed string from the function arguments from the standard PHP backtrace (debug_backtrace).
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $arr | by reference | array |
The array of the function arguments. |
Returns the detailed string from the function arguments.
Disables the trace.
If the trace is active, any error, warning or notice is traced to the standard file.
Enables the trace.
If the trace is active, any error, warning or notice is traced to the standard file.
Extracts the call stack from the standard PHP backtrace (debug_backtrace).
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $btrace | by value | array |
The backtrace. |
Returns the extracted call stack.
Formats the standard PHP backtrace (debug_backtrace).
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $btrace | by value | array |
The backtrace. |
Returns the formatted backtrace.
Returns the last error.
Returns the last error or an empty string if no error occurred so far.
This is the function for handling of the PHP errors. It is set in the error handler.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $errno | by value | int |
Error code. |
|
| $errstr | by value | string |
Error text. |
|
| $errfile | by value | string |
Source file where the error occurred. |
|
| $errline | by value | int |
Line number where the error occurred. |
It might throw an exception in the case of any errors.
This is the function for handling of the PHP exceptions. It should be called in the catch block to trace detailed information if an exception is thrown.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $ex | by value | \Throwable |
Thrown exception. |
|
| $errno | by value | int |
Error code. |
It might throw an exception in the case of any errors.
Initializes the error handler with parameters.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $parameters | by value | array |
Settings for logging as an associative array in the form key => value:
|
It might throw an exception in the case of any errors:
Generates the detailed string from the function arguments from the standard PHP backtrace (debug_backtrace).
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $args | by value | array |
The array of the function arguments. |
Returns the detailed string from the function arguments.
Stores the last error.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $error | by value | string |
The error text to be stored. |
Returns the state whether the trace is active or not.
If the trace is active, any error, warning or notice is traced to the standard file.
The trace is generally managed over the setting tracing_enabled. But you can also temporarily disable tracing, e.g. to keep the trace log clear when you make a check that can produce a trace entry, but it is a controlled noticed and should not clutter the trace.
Returns the state whether the trace is active or not.
Traces an error to the standard trace file (logs/trace.log).
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $etype | by value | string |
The type of the message to be traced. |
|
| $message | by value | string |
The message to be traced. |
Returns true if the message has been successfully trace, otherwise false.
It might throw an exception in the case of any errors:
This is an auxiliary function that cuts off the common part of the path.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $path | by value | string |
The path. |
Returns the cut path.
This is an auxiliary function for truncating long arguments.
| Name | Pass type | Value type | Default value | Description |
|---|---|---|---|---|
| $str | by value | ?string |
The string to be truncated. |
|
| $limit | by value | int |
The limit of the length after which the string is truncated. |
Returns the truncated string.