mergeError<T> static method

ResponseModel<T> mergeError<T>(
  1. DioError err, [
  2. ResponseModel<T>? responseModel
])

Implementation

static ResponseModel<T> mergeError<T>(DioError err,
    [ResponseModel<T>? responseModel]) {
  responseModel ??= ResponseModel<T>(requestOptions: err.requestOptions);
  responseModel.type = err.type.toString();
  final Response<dynamic>? errResponse = err.response;
  responseModel.requestOptions = err.requestOptions;
  responseModel.error = err.error;
  if (errResponse != null) {
    responseModel.headers = errResponse.headers;
    responseModel.redirects = errResponse.redirects;
    responseModel.extra = errResponse.extra;
    responseModel.statusCode = errResponse.statusCode;
    responseModel.statusMessage = errResponse.statusMessage;
    responseModel.data = errResponse.data;
  }
  responseModel.cookie = <String>[];
  return responseModel;
}