onError method

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

Called when an exception was occurred during the request.

Implementation

@override
void onError(
  DioException err,
  ErrorInterceptorHandler handler,
) {
  final callback = _onError;
  if (callback == null) {
    handler.next(err);
    return;
  }
  final dynamic dynamicCallback = callback;
  final result = dynamicCallback(err, handler);
  _observeInterceptorCallback(
    result,
    handler,
    (error, stackTrace) => handler.next(
      DioMixin.assureDioException(
        error,
        err.requestOptions,
        stackTrace,
      ),
    ),
  );
}