abstract class AbstractExceptionHandler implements ExceptionHandlerInterface (View source)

An abstract exception handler

Properties

protected LoggerInterface $logger
protected ThrowableStorageInterface $throwableStorage
protected array $options
protected $renderingOptions

Merged custom error view options from defaultRenderingOptions and of the first matching renderingGroup

Methods

void
injectLogger(LoggerInterface $logger)

No description

injectThrowableStorage(ThrowableStorageInterface $throwableStorage)

No description

void
setOptions(array $options)

Sets options of this exception handler.

__construct()

Constructs this exception handler - registers itself as the default exception handler.

void
handleException(object $exception)

Handles the given exception

void
echoExceptionWeb(Throwable $exception)

Echoes an exception for the web.

buildView(Throwable $exception, array $renderingOptions)

Prepares a view for rendering the custom error page.

applyLegacyViewOptions(ViewInterface $view, array $renderingOptions)

Sets legacy "option" properties to the view for backwards compatibility.

array
resolveCustomRenderingOptions(Throwable $exception)

Checks if custom rendering rules apply to the given $exception and returns those.

string
resolveRenderingGroup(Throwable $exception)

No description

bool
useCustomErrorView()

If a renderingGroup was successfully resolved via resolveRenderingGroup We will use a custom error view.

void
echoExceptionCli(Throwable $exception, bool $exceptionWasLogged)

Formats and echoes the exception and its previous exceptions (if any) for the command line

string
renderNestedExceptonsCli(Throwable $exception, string $exceptionMessage)

No description

string
renderSingleExceptionCli(Throwable $exception)

Renders a single exception including message, code and affected file

string
renderExceptionDetailCli(string $label, string $value)

Renders the given $value word-wrapped and prefixed with $label

array
splitExceptionMessage(string $exceptionMessage)

Splits the given string into subject and body according to following rules:

  • If the string is empty or does not contain more than one sentence nor line breaks, the subject will be equal to the string and body will be an empty string
  • Otherwise the subject is everything until the first line break or end of sentence, the body contains the rest

Details

void injectLogger(LoggerInterface $logger)

No description

Parameters

LoggerInterface $logger

Return Value

void

injectThrowableStorage(ThrowableStorageInterface $throwableStorage)

No description

Parameters

ThrowableStorageInterface $throwableStorage

void setOptions(array $options)

Sets options of this exception handler.

Parameters

array $options

Return Value

void

__construct()

Constructs this exception handler - registers itself as the default exception handler.

void handleException(object $exception)

Handles the given exception

Parameters

object $exception

The exception object - can be \Exception, or some type of \Throwable in PHP 7

Return Value

void

abstract protected void echoExceptionWeb(Throwable $exception)

Echoes an exception for the web.

Parameters

Throwable $exception

Return Value

void

protected ViewInterface buildView(Throwable $exception, array $renderingOptions)

Prepares a view for rendering the custom error page.

Parameters

Throwable $exception
array $renderingOptions

Rendering options as defined in the settings

Return Value

ViewInterface

protected ViewInterface applyLegacyViewOptions(ViewInterface $view, array $renderingOptions)

Sets legacy "option" properties to the view for backwards compatibility.

Parameters

ViewInterface $view
array $renderingOptions

Return Value

ViewInterface

protected array resolveCustomRenderingOptions(Throwable $exception)

Checks if custom rendering rules apply to the given $exception and returns those.

Parameters

Throwable $exception

Return Value

array

the custom rendering options, or NULL if no custom rendering is defined for this exception

protected string resolveRenderingGroup(Throwable $exception)

No description

Parameters

Throwable $exception

Return Value

string

name of the resolved renderingGroup or NULL if no group could be resolved

protected bool useCustomErrorView()

If a renderingGroup was successfully resolved via resolveRenderingGroup We will use a custom error view.

Also check for legacy 'templatePathAndFilename'

Return Value

bool

protected void echoExceptionCli(Throwable $exception, bool $exceptionWasLogged)

Formats and echoes the exception and its previous exceptions (if any) for the command line

Parameters

Throwable $exception
bool $exceptionWasLogged

Return Value

void

protected string renderNestedExceptonsCli(Throwable $exception, string $exceptionMessage)

No description

Parameters

Throwable $exception
string $exceptionMessage

Return Value

string

protected string renderSingleExceptionCli(Throwable $exception)

Renders a single exception including message, code and affected file

Parameters

Throwable $exception

Return Value

string

protected string renderExceptionDetailCli(string $label, string $value)

Renders the given $value word-wrapped and prefixed with $label

Parameters

string $label
string $value

Return Value

string

protected array splitExceptionMessage(string $exceptionMessage)

Splits the given string into subject and body according to following rules:

  • If the string is empty or does not contain more than one sentence nor line breaks, the subject will be equal to the string and body will be an empty string
  • Otherwise the subject is everything until the first line break or end of sentence, the body contains the rest

Parameters

string $exceptionMessage

Return Value

array

in the format array('subject' => '', 'body' => '');