class ProductionHandler implements HandlerInterface

Production handler.

Traits

Handler helper trait.

Properties

protected Request $request Request instance.
protected Response $response Response instance.
protected ViewFactory|null $view View factory instance.

Methods

bool
returnAs(string $function, array $mimes, string $partial)

Checks if we meet the requirements to return as a specific type.

bool
returnAsJson()

Should we return the error as JSON?

bool
returnAsXml()

Should we return the error as XML?

int
getStatusCode(Throwable $exception)

Returns the status code that we should send.

sendResponse(Response $response, Throwable $exception)

Sends response and adds any aditional headers.

__construct(Request $request, Response $response, ViewFactory|null $view = null)

Constructor.

array
getStatusCodeAndMessage(Throwable $exception)

Returns status code and message.

string
getExceptionAsJson(Throwable $exception)

Return a JSON representation of the exception.

string
getExceptionAsXml(Throwable $exception)

Return a XML representation of the exception.

string
getExceptionAsRenderedView(Throwable $exception)

Returns a rendered error view.

string
getExceptionAsPlainText(Throwable $exception)

Returns a plain text representation of the error.

string
getBody(Throwable $exception)

Returns a response body.

mixed
handle(Throwable $exception)

Handles the exception.

Details

in HandlerHelperTrait at line 35
protected bool returnAs(string $function, array $mimes, string $partial)

Checks if we meet the requirements to return as a specific type.

Parameters

string $function Required function
array $mimes Mimetypes
string $partial Partial mimetype

Return Value

bool

in HandlerHelperTrait at line 62
protected bool returnAsJson()

Should we return the error as JSON?

Return Value

bool

in HandlerHelperTrait at line 72
protected bool returnAsXml()

Should we return the error as XML?

Return Value

bool

in HandlerHelperTrait at line 83
protected int getStatusCode(Throwable $exception)

Returns the status code that we should send.

Parameters

Throwable $exception Exception

Return Value

int

in HandlerHelperTrait at line 94
protected sendResponse(Response $response, Throwable $exception)

Sends response and adds any aditional headers.

Parameters

Response $response Response
Throwable $exception Exception

at line 58
__construct(Request $request, Response $response, ViewFactory|null $view = null)

Constructor.

Parameters

Request $request Request
Response $response Response
ViewFactory|null $view View factory

at line 78
protected array getStatusCodeAndMessage(Throwable $exception)

Returns status code and message.

Parameters

Throwable $exception Exception

Return Value

array

at line 99
protected string getExceptionAsJson(Throwable $exception)

Return a JSON representation of the exception.

Parameters

Throwable $exception Exception

Return Value

string

at line 110
protected string getExceptionAsXml(Throwable $exception)

Return a XML representation of the exception.

Parameters

Throwable $exception Exception

Return Value

string

at line 129
protected string getExceptionAsRenderedView(Throwable $exception)

Returns a rendered error view.

Parameters

Throwable $exception Exception

Return Value

string

at line 152
protected string getExceptionAsPlainText(Throwable $exception)

Returns a plain text representation of the error.

Parameters

Throwable $exception Exception

Return Value

string

at line 165
protected string getBody(Throwable $exception)

Returns a response body.

Parameters

Throwable $exception Exception

Return Value

string

at line 196
mixed handle(Throwable $exception)

Handles the exception.

Parameters

Throwable $exception Exception to handle

Return Value

mixed