alexandroid/decompiled/jadx/sources/io/reactivex/rxjava3/internal/util/ExceptionHelper.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

110 lines
3.9 KiB
Java

package io.reactivex.rxjava3.internal.util;
import androidx.compose.runtime.BitVector$$ExternalSyntheticOutline0;
import defpackage.a$$ExternalSyntheticOutline0;
import io.reactivex.rxjava3.exceptions.CompositeException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
/* loaded from: classes10.dex */
public final class ExceptionHelper {
public static final Throwable TERMINATED = new Termination();
private ExceptionHelper() {
throw new IllegalStateException("No instances!");
}
public static boolean addThrowable(AtomicReference<Throwable> atomicReference, Throwable th) {
while (true) {
Throwable th2 = atomicReference.get();
if (th2 == TERMINATED) {
return false;
}
Throwable compositeException = th2 == null ? th : new CompositeException(th2, th);
while (!atomicReference.compareAndSet(th2, compositeException)) {
if (atomicReference.get() != th2) {
break;
}
}
return true;
}
}
public static NullPointerException createNullPointerException(String str) {
return new NullPointerException(nullWarning(str));
}
public static List<Throwable> flatten(Throwable th) {
ArrayList arrayList = new ArrayList();
ArrayDeque arrayDeque = new ArrayDeque();
arrayDeque.offer(th);
while (!arrayDeque.isEmpty()) {
Throwable th2 = (Throwable) arrayDeque.removeFirst();
if (th2 instanceof CompositeException) {
List<Throwable> exceptions = ((CompositeException) th2).getExceptions();
for (int size = exceptions.size() - 1; size >= 0; size--) {
arrayDeque.offerFirst(exceptions.get(size));
}
} else {
arrayList.add(th2);
}
}
return arrayList;
}
public static <T> T nullCheck(T t, String str) {
if (t != null) {
return t;
}
throw createNullPointerException(str);
}
public static String nullWarning(String str) {
return BitVector$$ExternalSyntheticOutline0.m(str, " Null values are generally not allowed in 3.x operators and sources.");
}
public static Throwable terminate(AtomicReference<Throwable> atomicReference) {
Throwable th = atomicReference.get();
Throwable th2 = TERMINATED;
return th != th2 ? atomicReference.getAndSet(th2) : th;
}
public static <E extends Throwable> Exception throwIfThrowable(Throwable th) throws Throwable {
if (th instanceof Exception) {
return (Exception) th;
}
throw th;
}
public static String timeoutMessage(long j, TimeUnit timeUnit) {
StringBuilder m = a$$ExternalSyntheticOutline0.m("The source did not signal an event for ", j, " ");
m.append(timeUnit.toString().toLowerCase());
m.append(" and has been terminated.");
return m.toString();
}
public static RuntimeException wrapOrThrow(Throwable th) {
if (th instanceof Error) {
throw ((Error) th);
}
return th instanceof RuntimeException ? (RuntimeException) th : new RuntimeException(th);
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class Termination extends Throwable {
private static final long serialVersionUID = -4649703670690200604L;
public Termination() {
super("No further exceptions");
}
@Override // java.lang.Throwable
public Throwable fillInStackTrace() {
return this;
}
}
}