httpErrorHandler function

void httpErrorHandler(
  1. HttpRequest req,
  2. Object error,
  3. StackTrace stackTrace
)

Every error of a request comes here. The ExceptionHandler of AppConfig reports it and decides the response.

Implementation

void httpErrorHandler(HttpRequest req, Object error, StackTrace stackTrace) {
  try {
    httpResponseHandler(renderError(req, error, stackTrace), req);
  } catch (sendError, sendStack) {
    /// the error answer failed too (eg. a bad header). report it and
    /// send a plain 500, so the client never waits for a timeout.
    try {
      Dox().config.exceptionHandler.report(sendError, sendStack);
    } catch (_) {
      Logger.danger('Sending the error failed: $sendError\n$sendStack');
    }
    _plainError(req.response);
  }
}