- Add the Codota plugin to your IDE and get smart completions
private void myMethod () {}
public HttpException(Response<?> response) { super(getMessage(response)); this.code = response.code(); this.message = response.message(); this.response = response; }
public HttpException(Response<?> response) { super(getMessage(response)); this.code = response.code(); this.message = response.message(); this.response = response; }
@Override public void onError(Throwable e) { if (e instanceof HttpException) { HttpException httpException = (HttpException) e; String message = httpException.getMessage(); onFailure(message); } else { onFailure(e.getMessage()); } onFinish(); }
@Test public void When_Call_OnIllegalMock_If_Method_Return_Type_Is_Single_Then_Get_Error_Single() throws NoSuchMethodException, IOException { Method method = Providers.class.getDeclaredMethod("single"); Rx2Retrofit annotation = PlaceholderRetrofitAnnotation.class.getAnnotation(Rx2Retrofit.class); Metadata<Rx2Retrofit> metadata = new Metadata(Providers.class, method, null, annotation, method.getGenericReturnType()); Single single = (Single) rx2RetrofitInterceptor.onIllegalMock(new AssertionError(), metadata); TestObserver<List<Mock>> subscriber = single.test(); subscriber.awaitTerminalEvent(); subscriber.assertNoValues(); HttpException httpException = (HttpException) subscriber.errors().get(0); assertThat(httpException.getMessage(), is("HTTP 404 null")); }
@Test public void When_Call_OnIllegalMock_If_Method_Return_Type_Is_Completable_Then_Get_Error_Completable() throws NoSuchMethodException, IOException { Method method = Providers.class.getDeclaredMethod("completable"); Rx2Retrofit annotation = PlaceholderRetrofitAnnotation.class.getAnnotation(Rx2Retrofit.class); Metadata<Rx2Retrofit> metadata = new Metadata(Providers.class, method, null, annotation, method.getGenericReturnType()); Completable completable = (Completable) rx2RetrofitInterceptor.onIllegalMock(new AssertionError(), metadata); TestObserver<Void> subscriber = completable.test(); subscriber.awaitTerminalEvent(); subscriber.assertNotComplete(); HttpException httpException = (HttpException) subscriber.errors().get(0); assertThat(httpException.getMessage(), is("HTTP 404 null")); }
HttpException httpException = (HttpException) e; ex = new ApiException(httpException, httpException.code()); ex.message = httpException.getMessage(); } else if (e instanceof SocketTimeoutException) { ex = new ApiException(e, ERROR.TIMEOUT_ERROR);
ex.message = httpException.getMessage(); return ex; } else if (e instanceof ServerException) {