Retrofit Observable Call()方法未设置baseUrl并抛出NP异常

时间:2017-06-16 15:13:54

标签: android exception retrofit retrofit2

当call()方法编译时,它不会设置Endpoint url并抛出NP Exception

        public Observable<ResultPojo> call() {
            final ResultPojo resultPojo;

            try {
                resultPojo = buildRestAdapter().registerSubDistributor
                        (subDistributorDetailModel.getRoleType(),
                                subDistributorDetailModel.getPassword(),
                                subDistributorDetailModel.getUserName(),
                                subDistributorDetailModel.getMobileNumber(),
                                subDistributorDetailModel.getAddress(),
                                subDistributorDetailModel.getFirmName(),
                                subDistributorDetailModel.getAge(),
                                subDistributorDetailModel.getFathersName());
            } catch (Exception e) {
                throw OnErrorThrowable.from(e);
            }
            return Observable.just(resultPojo);
        }
    });
}

“构建RestAdapter的方法,它返回apiManager对象”

private static SubDistributorApiManager buildRestAdapter(){

    Builder builder = new Builder()
            .setEndpoint(SubDistributorApiManager.BASE_URL);

    RestAdapter restAdapter = builder.build();
    SubDistributorApiManager apiManager = restAdapter.create(SubDistributorApiManager.class);


    return apiManager;
}

0 个答案:

没有答案