onError method
Called when an exception was occurred during the request.
Implementation
@override
Future<void> onError(
DioException err,
ErrorInterceptorHandler handler,
) async {
final response = err.response;
if (response == null) {
handler.next(err);
return;
}
try {
await saveCookies(response);
handler.next(err);
} catch (e, s) {
final exception = DioException(
requestOptions: response.requestOptions,
response: response,
type: DioExceptionType.unknown,
error: CookieManagerSaveException(
response: response,
error: e,
stackTrace: s,
dioException: err,
),
stackTrace: s,
);
handler.next(exception);
}
}