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

static $fatal_errors
static $transtable

Methods

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.

$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

handleFatalError()

No description

execute()

No description

Details

bool hasErrored()

Determine if an error has been found

Return Value

bool

setErrored($error)

Parameters

$error

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

Parameters

bool $suppression

$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

Parameters

$callback
  • The callback to call
$onErrorState
  • false if only call if no errors yet, true if only call if already errors, null for either

Return Value

$this

$this thenWhileGood(callable $callback)

Request that the callback is invoked if not errored

Parameters

callable $callback

Return Value

$this

$this thenIfErrored(callable $callback)

Request that the callback is invoked on error

Parameters

callable $callback

Return Value

$this

$this thenAlways(callable $callback)

Request that the callback is invoked always

Parameters

callable $callback

Return Value

$this

handleFatalError()

execute()