ErrorControlChain
class ErrorControlChain (View source)
Class ErrorControlChain
Runs a set of steps, optionally suppressing uncaught errors or exceptions which would otherwise be fatal that occur in each step. If an error does occur, subsequent steps are normally skipped, but can optionally be run anyway.
Usage:
$chain = new ErrorControlChain(); $chain->then($callback1)->then($callback2)->thenIfErrored($callback3)->execute();
WARNING: This class is experimental and designed specifically for use pre-startup in main.php It will likely be heavily refactored before the release of 3.2
Properties
public static | $fatal_errors | |||
protected | bool | $error | Is there an error? |
|
protected | array | $steps | List of steps |
|
protected | bool | $suppression | True if errors should be hidden |
|
protected | $handleFatalErrors | We can't unregister_shutdown_function, so this acts as a flag to enable handling |
||
protected | $originalDisplayErrors | We overload display_errors to hide errors during execution, so we need to remember the original to restore to |
||
protected | Exception | $lastException | Any exceptions passed through the chain |
|
public static | $transtable |
Methods
Sets whether errors are suppressed or not Notes:
- Errors cannot be suppressed if not handling errors.
Add this callback to the chain of callbacks to call along with the state that $error must be in this point in the chain for the callback to be called
Details
bool
hasErrored()
Determine if an error has been found
setErrored($error)
No description
setSuppression(bool $suppression)
Sets whether errors are suppressed or not Notes:
- Errors cannot be suppressed if not handling errors.
- Errors cannot be un-suppressed if original mode dis-allowed visible errors
protected
setDisplayErrors(mixed $errors)
Set display_errors
protected mixed
getDisplayErrors()
Get value of display_errors ini value
$this
then($callback, $onErrorState = false)
Add this callback to the chain of callbacks to call along with the state that $error must be in this point in the chain for the callback to be called
$this
thenWhileGood(callable $callback)
Request that the callback is invoked if not errored
$this
thenIfErrored(callable $callback)
Request that the callback is invoked on error
$this
thenAlways(callable $callback)
Request that the callback is invoked always
protected bool
lastErrorWasFatal()
Return true if the last error was fatal
protected
lastErrorWasMemoryExhaustion()
No description
protected
translateMemstring($memString)
No description
handleFatalError()
No description
execute()
No description
protected
step()
No description