无法从okhttp回调的onFailure中抛出异常

时间:2018-05-03 21:18:24

标签: android retrofit okhttp3 okhttp

当我尝试从onFailure方法抛出异常时,Android Studio强制我添加try catch块并且不允许向调用函数抛出异常。

protected void createUser(final UserRegister user) throws ApiException, RuntimeException {

    Call call = dbApi.registerUserAsync(user, new ApiCallback<UserRegistered>() {
        @Override
        public void onFailure(ApiException e, int i, Map<String, List<String>> map) {
            Timber.e("Exception in createUser: " + e.getMessage());
            throw e;
        }

0 个答案:

没有答案