convertResponse<BodyType, InnerType> method
Converts the received Response to a Response which has a body of the
type BodyType.
BodyType is the expected type of the resulting Response's body
(e.g., String or CustomObject).
If BodyType is a List or a BuiltList, InnerType is the type of the
generic parameter (e.g., convertResponse<List<CustomObject>, CustomObject>(response) ).
Implementation
@override
FutureOr<Response<BodyType>> convertResponse<BodyType, InnerType>(
Response response,
) async {
try {
return await delegate.convertResponse<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);
}
}