Variable RestInterfaceSettings.errorHandler
Optional handler used to render custom replies in case of errors.
class RestInterfaceSettings
{
// ...
@safe void delegate(HTTPServerRequest, HTTPServerResponse, RestErrorInformation) errorHandler
;
// ...
}
The handler needs to set the response status code to the provided
RestErrorInformation
value and can then write a custom
response body.
Note that the REST interface generator by default handles any exceptions thrown
during request handling and sents a JSON response with the error message. The
low level HTTPServerSettings
is not invoked.
If errorHandler
is not set, a JSON object with a single field "statusMessage"
will be sent. In debug builds, there may also be an additional
"statusDebugMessage" field that contains the full exception text, including a
possible stack trace.