PHP Class Autarky\Errors\ErrorHandlerManager

Inheritance: implements Autarky\Errors\ErrorHandlerManagerInterface
Show file Open project: autarky/framework Class Usage Examples

Protected Properties

Property Type Description
$defaultHandler Autarky\Errors\ErrorHandlerInterface | null
$handlers SplDoublyLinkedList
$resolver HandlerResolver
$rethrow boolean Re-throw exceptions rather than handling them.

Public Methods

Method Description
__construct ( HandlerResolver $resolver )
appendHandler ( $handler )
handle ( Exception $exception )
handleError ( integer $level, string $message, string $file = '', integer $line, array $context = [] ) Handle a PHP error.
handleShutdown ( ) : void Handle a PHP fatal error.
handleUncaught ( Exception $exception ) : Response Handle an uncaught exception. Does the same as handle(), but also sends the response, as we can assume that the exception happened outside of HttpKernelInterface::handle.
prependHandler ( $handler )
register ( )
setDefaultHandler ( Autarky\Errors\ErrorHandlerInterface $handler )
setRethrow ( $rethrow )
throwFatalErrorException ( ) : void Throw a FatalErrorException if an error has occured.

Protected Methods

Method Description
callHandler ( mixed $handler, Exception $exception ) : mixed Call an exception handler.
checkHandler ( $handler )
makeFatalErrorException ( ) : Symfony\Component\Debug\Exception\FatalErrorException | null Create a FatalErrorException out of the information stored on the last PHP error.
makeResponse ( mixed $response, Exception $exception ) : Response Transform an exception handler's response into a Response object.
matchesTypehint ( callable | Autarky\Errors\ErrorHandlerInterface $handler, Exception $exception ) : boolean Check if a handler's argument typehint matches an exception.

Method Details

__construct() public method

public __construct ( HandlerResolver $resolver )
$resolver HandlerResolver

appendHandler() public method

public appendHandler ( $handler )

callHandler() protected method

Call an exception handler.
protected callHandler ( mixed $handler, Exception $exception ) : mixed
$handler mixed
$exception Exception
return mixed

checkHandler() protected method

protected checkHandler ( $handler )

handle() public method

public handle ( Exception $exception )
$exception Exception

handleError() public method

Handle a PHP error.
public handleError ( integer $level, string $message, string $file = '', integer $line, array $context = [] )
$level integer
$message string
$file string
$line integer
$context array

handleShutdown() public method

Handle a PHP fatal error.
public handleShutdown ( ) : void
return void

handleUncaught() public method

Handle an uncaught exception. Does the same as handle(), but also sends the response, as we can assume that the exception happened outside of HttpKernelInterface::handle.
public handleUncaught ( Exception $exception ) : Response
$exception Exception
return Symfony\Component\HttpFoundation\Response

makeFatalErrorException() protected method

Create a FatalErrorException out of the information stored on the last PHP error.
protected makeFatalErrorException ( ) : Symfony\Component\Debug\Exception\FatalErrorException | null
return Symfony\Component\Debug\Exception\FatalErrorException | null

makeResponse() protected method

Transform an exception handler's response into a Response object.
protected makeResponse ( mixed $response, Exception $exception ) : Response
$response mixed
$exception Exception
return Symfony\Component\HttpFoundation\Response

matchesTypehint() protected method

Check if a handler's argument typehint matches an exception.
protected matchesTypehint ( callable | Autarky\Errors\ErrorHandlerInterface $handler, Exception $exception ) : boolean
$handler callable | Autarky\Errors\ErrorHandlerInterface
$exception Exception
return boolean

prependHandler() public method

public prependHandler ( $handler )

register() public method

public register ( )

setDefaultHandler() public method

public setDefaultHandler ( Autarky\Errors\ErrorHandlerInterface $handler )
$handler Autarky\Errors\ErrorHandlerInterface

setRethrow() public method

public setRethrow ( $rethrow )

throwFatalErrorException() public method

Throw a FatalErrorException if an error has occured.
public throwFatalErrorException ( ) : void
return void

Property Details

$defaultHandler protected property

protected ErrorHandlerInterface,Autarky\Errors|null $defaultHandler
return Autarky\Errors\ErrorHandlerInterface | null

$handlers protected property

protected SplDoublyLinkedList $handlers
return SplDoublyLinkedList

$resolver protected property

protected HandlerResolver,Autarky\Errors $resolver
return HandlerResolver

$rethrow protected property

Re-throw exceptions rather than handling them.
protected bool $rethrow
return boolean