class ViewFormatter implements HttpFormatter

A formatter for turning caught exceptions into "pretty" HTML error pages.

For certain known error types, we display pages with dedicated information relevant to this class of error, e.g. a page with a search form for HTTP 404 "Not Found" errors. We look for templates in the views/error directory.

If no specific template exists, a generic "Something went wrong" page will be displayed, optionally enriched with a more specific error message if found in the translation files.

Constants

ERRORS_WITH_VIEWS

Methods

__construct(Factory $view, TranslatorInterface $translator, SettingsRepositoryInterface $settings)

No description

ResponseInterface
format(HandledError $error, ServerRequestInterface $request)

<p>Create an HTTP Response to represent the error we are handling.</p>

Details

__construct(Factory $view, TranslatorInterface $translator, SettingsRepositoryInterface $settings)

Parameters

Factory $view
TranslatorInterface $translator
SettingsRepositoryInterface $settings

ResponseInterface format(HandledError $error, ServerRequestInterface $request)

<p>Create an HTTP Response to represent the error we are handling.</p>

<p>This method receives the error that was caught by Flarum's error handling stack, along with the current HTTP request instance. It should return an HTTP response that explains or represents what went wrong.</p>

Parameters

HandledError $error
ServerRequestInterface $request

Return Value

ResponseInterface