sendError static method

FutureOr<Response> sendError(
  1. Request req,
  2. dynamic error
)

Sends error serialized as ErrorDescription object and appropriate HTTP status code. If status code is not defined, it uses 500 status code.

  • req a HTTP request object.
  • error an error object to be sent.

Implementation

static FutureOr<Response> sendError(Request req, error) {
  error = error ?? <String, String>{};
  error = ApplicationException.unwrapError(error);

  return Response(error.status, body: json.encode(error));
}