\Charcoal\App\HandlerPhpError

Error Handler for PHP 7+ Throwables

Enhanced version of \Slim\Handlers\PhpError.

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()
error()
No public properties found
No constants found
determineContentType()
renderHtmlOutput()
renderHtmlTemplate()
setDisplayErrorDetails()
setError()
writeToErrorLog()
renderTextError()
renderJsonOutput()
renderXmlOutput()
renderHtmlError()
$container
$baseUrl
$knownContentTypes
$displayErrorDetails
$error
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

$error

$error : \Throwable

The caught throwable.

Type

\Throwable

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\PhpError

Inject dependencies from a Pimple Container.

Dependencies

  • array $settings — Slim's settings.

Parameters

\Pimple\Container $container

A dependencies container instance.

Returns

\Charcoal\App\Handler\PhpError

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, \Throwable  $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.

\Throwable $error

The caught Throwable object.

Returns

\Psr\Http\Message\ResponseInterface

displayErrorDetails()

displayErrorDetails() : boolean

Retrieves wether the the details of the error message should be displayed.

Returns

boolean

error()

error() : \Throwable

Retrieves the caught error.

Returns

\Throwable

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\PhpError

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

Parameters

boolean $state

Whether to display error details.

Returns

\Charcoal\App\Handler\PhpError

Chainable

setError()

setError(\Throwable  $error) : \Charcoal\App\Handler\PhpError

Set the caught error.

Parameters

\Throwable $error

The caught Throwable object.

Returns

\Charcoal\App\Handler\PhpError

Chainable

writeToErrorLog()

writeToErrorLog() : void

Write to the error log if displayErrorDetails is false

renderTextError()

renderTextError(\Throwable  $error) : string

Render error as Text.

Parameters

\Throwable $error

The caught Throwable object.

Returns

string

renderJsonOutput()

renderJsonOutput() : string

Render JSON Error

Returns

string

renderXmlOutput()

renderXmlOutput() : string

Render XML Error

Returns

string

renderHtmlError()

renderHtmlError(\Throwable  $error) : string

Render error as HTML.

Parameters

\Throwable $error

The caught Throwable 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