onError method

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

Called when an exception was occurred during the request.

Implementation

@override
void onError(DioError err, ErrorInterceptorHandler handler) {
  super.onError(err, handler);
  if (err.response != null) {
    DioResponseParser().parser(err.response).then((ResponseModel responseModel) {
      int? requestIndex = CommonData.requestingMap[err.requestOptions.hashCode];
      if (requestIndex != null) {
        CommonData.requestList[requestIndex].response = responseModel;
        CommonData.requestingMap.remove(err.requestOptions.hashCode);
      }
      _updateRequest();
    });
  }
}