convertError<BodyType, InnerType> method

  1. @override
FutureOr<Response> convertError<BodyType, InnerType>(
  1. Response response
)

Converts the received Response to a Response which has a body with the HTTP representation of the original body.

Implementation

@override
FutureOr<Response> convertError<BodyType, InnerType>(
  Response response,
) async {
  try {
    return await delegate.convertError<BodyType, InnerType>(response);
  } catch (error, stackTrace) {
    if (!isResponseSpecValidationError(error)) {
      Error.throwWithStackTrace(error, stackTrace);
    }

    final decorated = await debugResponses.decorate(
      response: response,
      error: error,
    );
    Error.throwWithStackTrace(decorated, stackTrace);
  }
}