\Charcoal\App\HandlerError

Error Handler

Enhanced version of \Slim\Handlers\NotFound.

It outputs the error message and diagnostic information in either JSON, XML, or HTML based on the Accept header.

Summary

Methods
Properties
Constants
__construct()
init()
setDependencies()
setContainer()
createConfig()
messageTitle()
renderHtmlMessage()
setBaseUrl()
baseUrl()
__invoke()
displayErrorDetails()
exception()
No public properties found
No constants found
determineContentType()
renderHtmlOutput()
renderHtmlTemplate()
setDisplayErrorDetails()
setException()
writeToErrorLog()
renderTextError()
renderJsonOutput()
renderXmlOutput()
renderHtmlError()
$container
$baseUrl
$knownContentTypes
$displayErrorDetails
$exception
N/A
createCdataSection()
No private properties found
N/A

Properties

$container

$container : \Pimple\Container

Container

Type

\Pimple\Container

$baseUrl

$baseUrl : string

URL for the home page

Type

string

$knownContentTypes

$knownContentTypes : array

Known handled content types

Type

array

$displayErrorDetails

$displayErrorDetails : boolean

Whether to output the error's details.

Type

boolean

$exception

$exception : \Exception

The caught exception.

Type

\Exception

Methods

__construct()

__construct(\Pimple\Container  $container) 

Return a new AbstractHandler object.

Parameters

\Pimple\Container $container

A dependencies container instance.

setDependencies()

setDependencies(\Pimple\Container  $container) : \Charcoal\App\Handler\Error

Inject dependencies from a Pimple Container.

Dependencies

  • array $settings — Slim's settings.

Parameters

\Pimple\Container $container

A dependencies container instance.

Returns

\Charcoal\App\Handler\Error

Chainable

setContainer()

setContainer(\Pimple\Container  $container) : \Charcoal\App\Handler\AbstractHandler

Set container for use with the template controller

Parameters

\Pimple\Container $container

A dependencies container instance.

Returns

\Charcoal\App\Handler\AbstractHandler

Chainable

createConfig()

createConfig(mixed|null  $data = null) : \Charcoal\App\Handler\ConfigInterface

ConfigurableTrait > createConfig()

Parameters

mixed|null $data

Optional config data.

Returns

\Charcoal\App\Handler\ConfigInterface

messageTitle()

messageTitle() : string

Render title of error

Returns

string

renderHtmlMessage()

renderHtmlMessage() : string

Render body of HTML error

Returns

string

setBaseUrl()

setBaseUrl(string|\Psr\Http\Message\UriInterface  $url) : \Charcoal\App\Handler\AbstractHandler

Set the base URL (home page).

Parameters

string|\Psr\Http\Message\UriInterface $url

A URL to the base URL.

Returns

\Charcoal\App\Handler\AbstractHandler

Chainable

baseUrl()

baseUrl() : string

Retrieves the URL for the home page.

Returns

string —

A URL representing the home page.

__invoke()

__invoke(\Psr\Http\Message\ServerRequestInterface  $request, \Psr\Http\Message\ResponseInterface  $response, \Exception  $error) : \Psr\Http\Message\ResponseInterface

Invoke Error Handler

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The most recent Request object.

\Psr\Http\Message\ResponseInterface $response

The most recent Response object.

\Exception $error

The caught Exception object.

Returns

\Psr\Http\Message\ResponseInterface

displayErrorDetails()

displayErrorDetails() : boolean

Retrieves the HTTP methods allowed by the current request.

Returns

boolean

exception()

exception() : \Exception

Retrieves the caught error.

Returns

\Exception

determineContentType()

determineContentType(\Psr\Http\Message\ServerRequestInterface  $request) : string

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

Parameters

\Psr\Http\Message\ServerRequestInterface $request

The most recent Request object.

Returns

string

renderHtmlOutput()

renderHtmlOutput() : string

Render HTML Error Page

Returns

string

renderHtmlTemplate()

renderHtmlTemplate() : string

Render HTML Error Page

Returns

string

setDisplayErrorDetails()

setDisplayErrorDetails(boolean  $state) : \Charcoal\App\Handler\Error

Set whether to display details of the error or a generic message.

Parameters

boolean $state

Whether to display error details.

Returns

\Charcoal\App\Handler\Error

Chainable

setException()

setException(\Exception  $error) : \Charcoal\App\Handler\Error

Set the caught error.

Parameters

\Exception $error

The caught Exception object.

Returns

\Charcoal\App\Handler\Error

Chainable

writeToErrorLog()

writeToErrorLog() : void

Write to the error log if displayErrorDetails is false

renderTextError()

renderTextError(\Exception  $error) : string

Render error as Text.

Parameters

\Exception $error

The caught Exception object.

Returns

string

renderJsonOutput()

renderJsonOutput() : string

Render JSON Error

Returns

string

renderXmlOutput()

renderXmlOutput() : string

Render XML Error

Returns

string

renderHtmlError()

renderHtmlError(\Exception  $error) : string

Render error as HTML.

Parameters

\Exception $error

The caught Exception object.

Returns

string

createCdataSection()

createCdataSection(string  $content) : string

Returns a CDATA section with the given content.

Parameters

string $content

The Character-Data to mark.

Returns

string