onError method

  1. @override
void onError(
  1. DioException error,
  2. ErrorInterceptorHandler handler
)

Called when an exception was occurred during the request.

Implementation

@override
void onError(DioException error, ErrorInterceptorHandler handler) {
  if (!enabled || !_shouldLog(error.requestOptions, FilterArgs(true, error.response?.data))) {
    handler.next(error);
    return;
  }

  final responseTime = _calculateElapsedTime(error.requestOptions);

  if (logError) {
    _logErrorDetails(error, responseTime);
  }

  handler.next(error);
}