onError method

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

Called when an exception was occurred during the request.

Implementation

@override
Future onError(DioException err, ErrorInterceptorHandler handler) async {
  // dio默认的错误实例,如果是没有网络,只能得到一个未知错误,无法精准的得知是否是无网络的情况
  /*if (err.type == DioExceptionType.unknown) {

  }*/
  // error统一处理
  FjNetException httpException = FjNetException.create(err);
  // 错误提示
  //err.error = httpException;
  LoggerUtil().logE(
      "接口异常 onError \n 异常信息:${httpException.toString()} \n 请求PATH: ${err.requestOptions.baseUrl + err.requestOptions.path} \n请求参数: ${err.requestOptions.queryParameters.toString()} ",
      tag: _TAG);
  super.onError(err, handler);
}