onError method
Called when an exception was occurred during the request.
Implementation
@override
void onError(DioException err, ErrorInterceptorHandler handler) {
final options = err.requestOptions;
final requestPath = '${options.baseUrl}${options.path}';
// Check for per-request override
final bool currentLogResponseError =
options.extra['logResponseError'] ?? logResponseError;
// Log the error request and error message
if (currentLogResponseError) {
logDebug('onError: ${options.method} request => $requestPath',
level: Level.error);
logDebug('onError: ${err.error}, Message: ${err.message}',
level: Level.debug);
}
// Call the super class to continue handling the error
return super.onError(err, handler);
}