package io.reactivex.internal.util; import io.reactivex.exceptions.CompositeException; import java.util.concurrent.atomic.AtomicReference; /* loaded from: classes2.dex */ public final class ExceptionHelper { public static final Throwable a = new Termination(); static final class Termination extends Throwable { Termination() { super("No further exceptions"); } @Override // java.lang.Throwable public Throwable fillInStackTrace() { return this; } } public static RuntimeException a(Throwable th) { if (th instanceof Error) { throw ((Error) th); } return th instanceof RuntimeException ? (RuntimeException) th : new RuntimeException(th); } public static boolean a(AtomicReference atomicReference, Throwable th) { Throwable th2; do { th2 = atomicReference.get(); if (th2 == a) { return false; } } while (!atomicReference.compareAndSet(th2, th2 == null ? th : new CompositeException(th2, th))); return true; } public static Throwable a(AtomicReference atomicReference) { Throwable th = atomicReference.get(); Throwable th2 = a; return th != th2 ? atomicReference.getAndSet(th2) : th; } }