vibe.d beta banner
get vibe.d
0.8.4

Asynchronous I/O that doesn’t get in your way, written in D

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.statusCode 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.errorPageHandler 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.

Authors

Sönke Ludwig, Михаил Страшун, Mathias 'Geod24' Lang

Copyright

© 2012-2018 RejectedSoftware e.K.

License

Subject to the terms of the MIT license, as written in the included LICENSE.txt file.