onCall method

  1. @override
FutureOr<Message> onCall(
  1. Request request, [
  2. T? exception,
  3. StackTrace? stackTrace
])
override

Implementation

@override
FutureOr<Message> onCall(Request request,
    [T? exception, StackTrace? stackTrace]) async {
  try {
    //TODO: Change
    var e = await onError(request, exception!, stackTrace!);
    if (e is Response) {
      if (exception is StyleException) {
        e.statusCode = exception.statusCode;
      }
      return e;
    } else {
      //
      if (e is Future) {
        var r = await e;
        if (r is Message) {
          return r;
        } else {
          return request.response(r);
        }
      }
      if (e is Message) {
        return e;
      } else {
        return request.response(Body(e));
      }
    }
  } on Exception {
    rethrow;
  }
}