@Override public void onNext(Response<R> response) { if (response.isSuccessful()) { observer.onNext(response.body()); } else { terminated = true; Throwable t = new HttpException(response); try { observer.onError(t); } catch (Throwable inner) { Exceptions.throwIfFatal(inner); RxJavaPlugins.onError(new CompositeException(t, inner)); } } }
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions", "deprecation"}) private static boolean isHttpException(Throwable cause, int httpCode) { if (isException(cause, retrofit2.HttpException.class)) { retrofit2.HttpException httpException = (retrofit2.HttpException) getCause(cause, retrofit2.HttpException.class); return httpCode == httpException.code(); } if (isException(cause, retrofit2.adapter.rxjava2.HttpException.class)) { retrofit2.adapter.rxjava2.HttpException httpException = (retrofit2.adapter.rxjava2.HttpException) getCause(cause, retrofit2.adapter.rxjava2.HttpException.class); return httpCode == httpException.code(); } return false; }
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "ConstantConditions", "deprecation"}) private static boolean isHttpException(Throwable cause, int httpCode) { if (isException(cause, retrofit2.HttpException.class)) { retrofit2.HttpException httpException = (retrofit2.HttpException) getCause(cause, retrofit2.HttpException.class); return httpCode == httpException.code(); } if (isException(cause, retrofit2.adapter.rxjava2.HttpException.class)) { retrofit2.adapter.rxjava2.HttpException httpException = (retrofit2.adapter.rxjava2.HttpException) getCause(cause, retrofit2.adapter.rxjava2.HttpException.class); return httpCode == httpException.code(); } return false; }
(retrofit2.adapter.rxjava2.HttpException) getCause(cause, retrofit2.adapter.rxjava2.HttpException.class); message = httpCode2MessageResource(httpException.code());