Skip to content

API: The Exceptable Interface

Adrian edited this page Mar 27, 2024 · 14 revisions

at\exceptable\Exceptable

Augmented interface for exceptional exceptions.

instance methods

  • Exceptable::__construct()

    public __construct( Error $e = null, array $context = [], Throwable $previous = null )
    

    Object constructor.

    • parameters:
      • Error $e: The Error case to base the Exceptable on.
      • array $context: Additional error context.
      • Throwable $previous: Previous exception, if any.
  • Exceptable::context()

    public context() : array
    

    Gets contextual information about the Exceptable.

    • returns array: Contextual information provided on construct, as well as the error __message__ and __rootMessage__.
  • Exceptable::error()

    public error() : Error
    

    Gets the Exceptable's Error case.

    • returns Error
  • Exceptable::has()

    public has( Error $e ) : bool
    

    Does the Exceptable contain the given Error case anywhere in its error chain?

    • parameters:
      • Error $e: The Error case to compare against
    • returns bool: True if the given Error belongs to the current or a previous Exceptable; false otherwise
  • Exceptable::is()

    public is( Error $e ) : bool
    

    Does the Exceptable match the given Error case?

    • parameters:
      • Error $e: The Error case to compare against
    • returns bool: True if the given Error belongs to the Exceptable; false otherwise
  • Exceptable::root()

    public root() : Throwable
    

    Traverses the chain of previous exception(s) and gets the root exception. This may be the same as the top-level exception, i.e., if there are no previous exceptions.

    • returns Throwable