convertError<BodyType, InnerType> method
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 {
final Response jsonResponse = await jsonConverter.convertResponse(response);
dynamic body;
try {
// try to deserialize using wireName
body ??= _deserialize(jsonResponse.body);
} catch (_) {
final type = errorType;
// or check provided error type
if (type != null) {
final serializer = serializers.serializerForType(type);
if (serializer != null) {
body = serializers.deserializeWith(serializer, jsonResponse.body);
}
}
body ??= jsonResponse.body;
}
return jsonResponse.copyWith(body: body);
}