Skip to content

API: The Handler Class

Adrian Testa-Avila edited this page Jan 28, 2017 · 9 revisions

at\exceptable\Handler

Manages a registry of callback functions ("handlers") for errors, uncaught exceptions, and shutdown.

instance methods

public mixed during( callable $callback [, mixed ...$arguments] )

Registers this handler to invoke a callback, and then restores the previous handler(s).

  • parameters:
    • callable $callback
      The callback to invoke.
    • mixed ...$arguments
      Argument(s) to pass to the callback.
  • returns: mixed
    The value returned from the callback.

public Handler onError( callable $handler [, int $types] )

Adds an error handler.

  • parameters:
    • callable $handler
      The handler to add. Must be suitable for use with set_error_handler.
    • int $types
      The error types the handler should be invoked for (a bitmask of E_* constants). Defaults to "any error type."
  • returns: at\exceptable\Handler
    The Handler instance.

public Handler onException( callable $handler [, int $types] )

Adds a handler for uncaught exceptions.

  • parameters:
    • callable $handler
      The handler to add. Must be suitable for use with set_exception_handler.
    • int $severity
      The exception severities the handler should be invoked for (a bitmask of Exceptable severity constants). Defaults to "any severity."
  • returns: at\exceptable\Handler
    The Handler instance.

public Handler onShutdown( callable $handler [, ...$arguments] )

Adds a shutdown handler.
Note, shutdown handlers should not be registered to handle fatal errors. If the shutdown is due to a fatal error, then then appropriate registered error handlers will be invoked; and should be handled there.

  • parameters:
    • callable $handler
      The handler to add. Must be suitable for use with register_shutdown_function.
    • mixed $arguments
      Argument(s) to pass to the handler on shutdown.
  • returns: at\exceptable\Handler
    The Handler instance.

public Handler register( void )

Starts the Handler ("makes its registered handlers "active").

  • returns: at\exceptable\Handler
    The Handler instance.

public Handler throw( [int $types] )

Sets error types which should be intercepted and thrown as ErrorExceptions.

  • parameters:
    • int $types
      The error types to be thrown. Defaults to E_ERROR|E_WARNING; use 0 to stop throwing.
  • returns: at\exceptable\Handler
    The Handler instance.

public Handler unregister( void )

Stops the Handler (makes its registered handlers "inactive").

  • returns: at\exceptable\Handler
    The Handler instance.

Clone this wiki locally