call method

Future<Response> call(
  1. Object? error,
  2. StackTrace trace
)

Implementation

Future<http.Response> call(Object? error, StackTrace trace) async =>
    switch (error) {
      MethodNotAllowed() =>
        await onMethodNotAllowed?.call(error) ?? methodNotAllowed(),
      UnmatchedTarget() =>
        await onUnmatchedTarget?.call(error) ?? badRequest(),
      CollectionNotFound() => await onCollectionNotFound?.call(error) ??
          notFound(OutboundErrorDocument([
            ErrorObject(
              title: 'Collection Not Found',
              detail: 'Type: ${error.type}',
            )
          ])),
      ResourceNotFound() => await onResourceNotFound?.call(error) ??
          notFound(OutboundErrorDocument([
            ErrorObject(
              title: 'Resource Not Found',
              detail: 'Type: ${error.type}, id: ${error.id}',
            )
          ])),
      RelationshipNotFound() => await onRelationshipNotFound?.call(error) ??
          notFound(OutboundErrorDocument([
            ErrorObject(
              title: 'Relationship Not Found',
              detail: 'Type: ${error.type}'
                  ', id: ${error.id}'
                  ', relationship: ${error.relationship}',
            )
          ])),
      UnsupportedMediaType() => unsupportedMediaType(),
      Unacceptable() => unacceptable(),
      _ => await onError?.call(error, trace) ??
          response(500,
              document: OutboundErrorDocument(
                  [ErrorObject(title: 'Internal Server Error')]))
    };