UserFrosting API

NotFoundExceptionHandler extends HttpExceptionHandler

Handler for NotFoundExceptions.

Tags
author

Alex Weissman (https://alexanderweissman.com)

Table of Contents

$ci ContainerInterface
$request ServerRequestInterface
$response ResponseInterface
$exception Throwable
$renderer ErrorRendererInterface
$contentType string
$statusCode int
$displayErrorDetails Tells the handler whether or not to output detailed error information to the client. bool
$knownContentTypes Known handled content types. array
handle() Custom handling for NotFoundExceptions. Always render a generic response! ResponseInterface
writeToErrorLog() Write to the error log. mixed
determineStatusCode() Resolve the status code to return in the response from this handler. int
determineUserMessages() Resolve a list of error messages to present to the end user. array
__construct() Create a new ExceptionHandler object. mixed
handle() Handle the caught exception. ResponseInterface
renderDebugResponse() Render a detailed response with debugging information. ResponseInterface
renderGenericResponse() Render a generic, user-friendly response without sensitive debugging information. ResponseInterface
writeAlerts() Write user-friendly error messages to the alert message stream. mixed
determineRenderer() Determine which renderer to use based on content type Overloaded $renderer from calling class takes precedence over all. ErrorRendererInterface
logError() Monolog logging for errors. mixed
determineContentType() Determine which content type we know about is wanted using Accept header. string

Properties

$displayErrorDetails

Tells the handler whether or not to output detailed error information to the client.

protected bool $displayErrorDetails
Each handler may choose if and how to implement this.

$knownContentTypes

Known handled content types.

protected array $knownContentTypes = ['application/json', 'application/xml', 'text/xml', 'text/html', 'text/plain']

Methods

handle()

Custom handling for NotFoundExceptions. Always render a generic response!

public handle( ) : ResponseInterface
Return values
ResponseInterface

writeToErrorLog()

Write to the error log.

public writeToErrorLog( ) : mixed
Return values
mixed

determineStatusCode()

Resolve the status code to return in the response from this handler.

protected determineStatusCode( ) : int
Return values
int

determineUserMessages()

Resolve a list of error messages to present to the end user.

protected determineUserMessages( ) : array
Return values
array

__construct()

Create a new ExceptionHandler object.

public __construct( $ci : ContainerInterface , $request : ServerRequestInterface , $response : ResponseInterface , $exception : Throwable [, $displayErrorDetails : bool = false ] ) : mixed
Parameters
$ci : ContainerInterface
$request : ServerRequestInterface

The most recent Request object

$response : ResponseInterface

The most recent Response object

$exception : Throwable

The caught Exception object

$displayErrorDetails : bool = false
Return values
mixed

handle()

Handle the caught exception.

public handle( ) : ResponseInterface

The handler may render a detailed debugging error page, a generic error page, write to logs, and/or add messages to the alert stream.

Return values
ResponseInterface

renderDebugResponse()

Render a detailed response with debugging information.

public renderDebugResponse( ) : ResponseInterface
Return values
ResponseInterface

renderGenericResponse()

Render a generic, user-friendly response without sensitive debugging information.

public renderGenericResponse( ) : ResponseInterface
Return values
ResponseInterface

writeAlerts()

Write user-friendly error messages to the alert message stream.

public writeAlerts( ) : mixed
Return values
mixed

logError()

Monolog logging for errors.

protected logError( $message : string ) : mixed
Parameters
$message : string
Return values
mixed

determineContentType()

Determine which content type we know about is wanted using Accept header.

protected determineContentType( $request : ServerRequestInterface [, $ajaxDebug : bool = false ] ) : string

Note: This method is a bare-bones implementation designed specifically for Slim's error handling requirements. Consider a fully-feature solution such as willdurand/negotiation for any other situation.

Parameters
$request : ServerRequestInterface
$ajaxDebug : bool = false
Return values
string

Search results