package retrofit2.adapter.rxjava3; import io.reactivex.rxjava3.exceptions.CompositeException; import o.AbstractC13163fSk; import o.C13147fSI; import o.C13418fZu; import o.InterfaceC13174fSv; import o.fSJ; import retrofit2.Response; /* loaded from: classes.dex */ final class BodyObservable extends AbstractC13163fSk { private final AbstractC13163fSk> upstream; /* JADX INFO: Access modifiers changed from: package-private */ public BodyObservable(AbstractC13163fSk> abstractC13163fSk) { this.upstream = abstractC13163fSk; } @Override // o.AbstractC13163fSk public final void subscribeActual(InterfaceC13174fSv interfaceC13174fSv) { this.upstream.subscribe(new BodyObserver(interfaceC13174fSv)); } /* loaded from: classes6.dex */ static class BodyObserver implements InterfaceC13174fSv> { private final InterfaceC13174fSv observer; private boolean terminated; BodyObserver(InterfaceC13174fSv interfaceC13174fSv) { this.observer = interfaceC13174fSv; } @Override // o.InterfaceC13174fSv public void onSubscribe(fSJ fsj) { this.observer.onSubscribe(fsj); } @Override // o.InterfaceC13174fSv public void onNext(Response response) { if (response.isSuccessful()) { this.observer.onNext(response.body()); return; } this.terminated = true; HttpException httpException = new HttpException(response); try { this.observer.onError(httpException); } catch (Throwable th) { C13147fSI.c(th); C13418fZu.c(new CompositeException(httpException, th)); } } @Override // o.InterfaceC13174fSv public void onComplete() { if (this.terminated) { return; } this.observer.onComplete(); } @Override // o.InterfaceC13174fSv public void onError(Throwable th) { if (!this.terminated) { this.observer.onError(th); return; } AssertionError assertionError = new AssertionError("This should never happen! Report as a bug with the full stacktrace."); assertionError.initCause(th); C13418fZu.c(assertionError); } } }