Dio: 为什么拦截器里拦截不到异常呢?

Created on 20 Apr 2020  ·  4Comments  ·  Source: flutterchina/dio

image

throw assureDioError(e, options);会抛出异常!

  checkCancelled(cancelToken);
  if (statusOk) {
    return checkIfNeedEnqueue(interceptors.responseLock, () => ret);
  } else {
    throw DioError(
      response: ret,
      error: 'Http status error [${responseBody.statusCode}]',
      type: DioErrorType.RESPONSE,
    );
  }
} catch (e) {
  throw assureDioError(e, options);
}

}

stale

Most helpful comment

同问,没有任何办法捕捉到错误!!!!

All 4 comments

同问,没有任何办法捕捉到错误!!!!

Same here! Can't capture DioError.

在future后 加上.catchError就可以,但是这个不是我想要的,外层try{}catch依然不可以(可以捕捉到自己抛的,但是dio的就不行),不知道为何。

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings