onError method
Called when an exception was occurred during the request.
Implementation
@override
void onError(DioException exception, ErrorInterceptorHandler handler) {
if (error) {
if (exception.type == DioExceptionType.badResponse) {
final uri = exception.response?.requestOptions.uri;
_printBoxed(
_logPrintError,
header:
'DioException ║ Status: ${exception.response?.statusCode} ${exception.response?.statusMessage}',
text: uri.toString(),
);
if (exception.response != null && exception.response?.data != null) {
_logPrintError('╔ ${exception.type.toString()}');
_printResponse(_logPrintError, exception.response!);
}
_printLine(_logPrintError, '╚');
_logPrintError('');
} else {
_printBoxed(
_logPrintError,
header: 'DioException ║ ${exception.type}',
text: exception.message,
);
_printRequestHeader(_logPrintError, exception.requestOptions);
}
}
super.onError(exception, handler);
}