resolve property
Future<ApiResponse<BodyType, InnerType> >
get
resolve
Runs the request's interceptors over this response.
An interceptor that throws no longer disappears: the chain stops, the failure is logged, and the returned response carries the exception on error/cause so callers can see that resolution was incomplete.
Implementation
Future<ApiResponse<BodyType, InnerType>> get resolve async {
var response = this;
for (final interceptor in request.interceptors) {
try {
response = await (isSuccessful
? interceptor.onResponse(response)
: interceptor.onError(response));
} catch (e, trace) {
ApiConfig().log(
'interceptor ${interceptor.runtimeType} threw while resolving '
'${request.method} ${request.path}: $e\n$trace',
);
return response.copyWith(
error:
response.error ??
ApiError('$e', ApiConfig.interceptorFailureCode),
cause: e,
stackTrace: trace,
);
}
}
return response;
}