what-the-bank/sources/io/reactivex/rxjava3/exceptions/CompositeException.java

230 lines
8.2 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package io.reactivex.rxjava3.exceptions;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.LinkedHashSet;
import java.util.List;
/* loaded from: classes.dex */
public final class CompositeException extends RuntimeException {
private final List<Throwable> b;
private Throwable c;
private final String d;
public CompositeException(Throwable... thArr) {
this(Arrays.asList(thArr));
}
public CompositeException(Iterable<? extends Throwable> iterable) {
LinkedHashSet linkedHashSet = new LinkedHashSet();
if (iterable != null) {
for (Throwable th : iterable) {
if (th instanceof CompositeException) {
linkedHashSet.addAll(((CompositeException) th).b);
} else if (th != null) {
linkedHashSet.add(th);
} else {
linkedHashSet.add(new NullPointerException("Throwable was null!"));
}
}
} else {
linkedHashSet.add(new NullPointerException("errors was null"));
}
if (linkedHashSet.isEmpty()) {
throw new IllegalArgumentException("errors is empty");
}
List<Throwable> unmodifiableList = Collections.unmodifiableList(new ArrayList(linkedHashSet));
this.b = unmodifiableList;
StringBuilder sb = new StringBuilder();
sb.append(unmodifiableList.size());
sb.append(" exceptions occurred. ");
this.d = sb.toString();
}
@Override // java.lang.Throwable
public final Throwable getCause() {
Throwable th;
int i;
synchronized (this) {
if (this.c == null) {
String property = System.getProperty("line.separator");
if (this.b.size() > 1) {
IdentityHashMap identityHashMap = new IdentityHashMap();
StringBuilder sb = new StringBuilder();
sb.append("Multiple exceptions (");
sb.append(this.b.size());
sb.append(")");
sb.append(property);
for (Throwable th2 : this.b) {
int i2 = 0;
while (true) {
if (th2 != null) {
for (int i3 = 0; i3 < i2; i3++) {
sb.append(" ");
}
sb.append("|-- ");
sb.append(th2.getClass().getCanonicalName());
sb.append(": ");
String message = th2.getMessage();
if (message != null && message.contains(property)) {
sb.append(property);
for (String str : message.split(property)) {
for (int i4 = 0; i4 < i2 + 2; i4++) {
sb.append(" ");
}
sb.append(str);
sb.append(property);
}
} else {
sb.append(message);
sb.append(property);
}
int i5 = 0;
while (true) {
i = i2 + 2;
if (i5 >= i) {
break;
}
sb.append(" ");
i5++;
}
StackTraceElement[] stackTrace = th2.getStackTrace();
if (stackTrace.length > 0) {
sb.append("at ");
sb.append(stackTrace[0]);
sb.append(property);
}
if (!identityHashMap.containsKey(th2)) {
identityHashMap.put(th2, Boolean.TRUE);
th2 = th2.getCause();
i2++;
} else {
Throwable cause = th2.getCause();
if (cause != null) {
for (int i6 = 0; i6 < i; i6++) {
sb.append(" ");
}
sb.append("|-- ");
sb.append("(cause not expanded again) ");
sb.append(cause.getClass().getCanonicalName());
sb.append(": ");
sb.append(cause.getMessage());
sb.append(property);
}
}
}
}
}
this.c = new RVV(sb.toString().trim());
} else {
this.c = this.b.get(0);
}
}
th = this.c;
}
return th;
}
@Override // java.lang.Throwable
public final void printStackTrace() {
printStackTrace(System.err);
}
@Override // java.lang.Throwable
public final void printStackTrace(PrintStream printStream) {
b(new LWm(printStream));
}
@Override // java.lang.Throwable
public final void printStackTrace(PrintWriter printWriter) {
b(new Sts(printWriter));
}
private void b(IeS ieS) {
ieS.e(this).e("\n");
for (StackTraceElement stackTraceElement : getStackTrace()) {
ieS.e("\tat ").e(stackTraceElement).e("\n");
}
int i = 1;
for (Throwable th : this.b) {
ieS.e(" ComposedException ").e(Integer.valueOf(i)).e(" :\n");
String str = "\t";
while (true) {
ieS.e(str).e(th).e('\n');
for (StackTraceElement stackTraceElement2 : th.getStackTrace()) {
ieS.e("\t\tat ").e(stackTraceElement2).e('\n');
}
if (th.getCause() != null) {
ieS.e("\tCaused by: ");
th = th.getCause();
str = "";
}
}
i++;
}
ieS.e("\n");
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public static abstract class IeS {
abstract IeS e(Object obj);
IeS() {
}
}
/* loaded from: classes.dex */
static final class LWm extends IeS {
private final PrintStream a;
@Override // io.reactivex.rxjava3.exceptions.CompositeException.IeS
final /* synthetic */ IeS e(Object obj) {
this.a.print(obj);
return this;
}
LWm(PrintStream printStream) {
this.a = printStream;
}
}
/* loaded from: classes.dex */
static final class Sts extends IeS {
private final PrintWriter b;
@Override // io.reactivex.rxjava3.exceptions.CompositeException.IeS
final /* synthetic */ IeS e(Object obj) {
this.b.print(obj);
return this;
}
Sts(PrintWriter printWriter) {
this.b = printWriter;
}
}
/* loaded from: classes.dex */
static final class RVV extends RuntimeException {
RVV(String str) {
super(str);
}
@Override // java.lang.Throwable
public final Throwable fillInStackTrace() {
synchronized (this) {
}
return this;
}
}
@Override // java.lang.Throwable
public final String getMessage() {
return this.d;
}
}