class JsonApiFormatter implements HttpFormatter

A formatter to render exceptions as valid {JSON:API} error object.

See https://jsonapi.org/format/1.0/#errors.

Methods

__construct($includeTrace = false)

No description

ResponseInterface
format(HandledError $error, ServerRequestInterface $request)

Create an HTTP Response to represent the error we are handling.

Details

__construct($includeTrace = false)

Parameters

$includeTrace

ResponseInterface format(HandledError $error, ServerRequestInterface $request)

Create an HTTP Response to represent the error we are handling.

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.

Parameters

HandledError $error
ServerRequestInterface $request

Return Value

ResponseInterface