我正在使用apollo客户端https://github.com/apollographql/apollo-android来查询Graphql API。在Graphql Server中,我们返回HTTPS状态
return Response.status( Status.BAD_REQUEST ).entity( exception.getMessage() ).build();如何获取客户端响应的HTTPS状态码?
客户端代码
ApolloCall<T> apolloCall = apolloClient.query( query );
Response<T> response = Rx2Apollo.from( apolloCall ).onErrorReturn( throwable -> null ).blockingFirst();我主要想知道这个错误是客户端异常还是服务器异常。
发布于 2021-06-08 05:33:00
您可以删除.onErrorReturn( throwable -> null )部件,并且HTTP将以ApolloHttpException的形式在onError中返回,您可以在其上调用.code()来获取HTTP码。
https://stackoverflow.com/questions/66025787
复制相似问题