onError method
Called when an exception was occurred during the request.
Implementation
@override
void onError(DioException error, handler) async {
if (isResponseAndRetry &&
error.response?.statusCode == HttpStatus.unauthorized) {
try {
final response =
await authHandler.refreshTokenCallback(error.requestOptions);
if (response != null) {
handler.resolve(response);
} else {
handler.next(error);
}
} catch (e) {
print(e);
}
} else {
await exceptionHandler.handle(error, extra: error.requestOptions.extra);
handler.next(error);
}
}