onError method

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

Called when an exception was occurred during the request.

Implementation

@override
void onError(DioException err, ErrorInterceptorHandler handler) {
  _handleCompletion(
    err.requestOptions,
    statusCode: err.response?.statusCode,
    responseData: err.response?.data,
    responseHeaders: err.response != null
        ? _convertDioHeaders(err.response!.headers)
        : null,
    isError: true,
    errorMessage: err.message,
  );

  handler.next(err);
}