onApplicationException method

FutureOr<Response> onApplicationException(
  1. PharaohError error,
  2. Request request,
  3. Response response
)

Implementation

FutureOr<Response> onApplicationException(
  PharaohError error,
  Request request,
  Response response,
) async {
  final exception = error.exception;
  if (exception is RequestValidationError) {
    return response.json(exception, statusCode: HttpStatus.badRequest);
  }
  return response.internalServerError(exception.toString());
}