mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-14 18:07:16 +01:00
241 lines
9.9 KiB
Java
241 lines
9.9 KiB
Java
package io.reactivex.rxjava3.exceptions;
|
|
|
|
import com.amazon.alexa.accessory.internal.util.DeviceDatabaseUtils;
|
|
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
|
|
import io.reactivex.rxjava3.annotations.NonNull;
|
|
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;
|
|
import org.apache.commons.lang3.SystemProperties;
|
|
import rx.Single$$ExternalSyntheticBUOutline0;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes18.dex */
|
|
public final class CompositeException extends RuntimeException {
|
|
private static final long serialVersionUID = 3026362227162912146L;
|
|
private Throwable cause;
|
|
private final List<Throwable> exceptions;
|
|
private final String message;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class ExceptionOverview extends RuntimeException {
|
|
private static final long serialVersionUID = 3875212506787802066L;
|
|
|
|
public ExceptionOverview(String str) {
|
|
super(str);
|
|
}
|
|
|
|
@Override // java.lang.Throwable
|
|
public synchronized Throwable fillInStackTrace() {
|
|
return this;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static abstract class PrintStreamOrWriter {
|
|
public abstract PrintStreamOrWriter append(Object obj);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class WrappedPrintStream extends PrintStreamOrWriter {
|
|
private final PrintStream printStream;
|
|
|
|
public WrappedPrintStream(PrintStream printStream) {
|
|
this.printStream = printStream;
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.exceptions.CompositeException.PrintStreamOrWriter
|
|
public WrappedPrintStream append(Object obj) {
|
|
this.printStream.print(obj);
|
|
return this;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class WrappedPrintWriter extends PrintStreamOrWriter {
|
|
private final PrintWriter printWriter;
|
|
|
|
public WrappedPrintWriter(PrintWriter printWriter) {
|
|
this.printWriter = printWriter;
|
|
}
|
|
|
|
@Override // io.reactivex.rxjava3.exceptions.CompositeException.PrintStreamOrWriter
|
|
public WrappedPrintWriter append(Object obj) {
|
|
this.printWriter.print(obj);
|
|
return this;
|
|
}
|
|
}
|
|
|
|
public CompositeException(@NonNull Iterable<? extends Throwable> iterable) {
|
|
LinkedHashSet linkedHashSet = new LinkedHashSet();
|
|
if (iterable != null) {
|
|
for (Throwable th : iterable) {
|
|
if (th instanceof CompositeException) {
|
|
linkedHashSet.addAll(((CompositeException) th).getExceptions());
|
|
} 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()) {
|
|
Single$$ExternalSyntheticBUOutline0.m$3("errors is empty");
|
|
throw null;
|
|
}
|
|
List<Throwable> unmodifiableList = Collections.unmodifiableList(new ArrayList(linkedHashSet));
|
|
this.exceptions = unmodifiableList;
|
|
this.message = unmodifiableList.size() + " exceptions occurred. ";
|
|
}
|
|
|
|
private void appendStackTrace(PrintStreamOrWriter printStreamOrWriter, Throwable th, String str) {
|
|
printStreamOrWriter.append(str).append(th).append('\n');
|
|
for (StackTraceElement stackTraceElement : th.getStackTrace()) {
|
|
printStreamOrWriter.append("\t\tat ").append(stackTraceElement).append('\n');
|
|
}
|
|
if (th.getCause() != null) {
|
|
printStreamOrWriter.append("\tCaused by: ");
|
|
appendStackTrace(printStreamOrWriter, th.getCause(), "");
|
|
}
|
|
}
|
|
|
|
private void printStackTrace(PrintStreamOrWriter printStreamOrWriter) {
|
|
printStreamOrWriter.append(this).append("\n");
|
|
for (StackTraceElement stackTraceElement : getStackTrace()) {
|
|
printStreamOrWriter.append("\tat ").append(stackTraceElement).append("\n");
|
|
}
|
|
int i = 1;
|
|
for (Throwable th : this.exceptions) {
|
|
printStreamOrWriter.append(" ComposedException ").append(Integer.valueOf(i)).append(" :\n");
|
|
appendStackTrace(printStreamOrWriter, th, DeviceDatabaseUtils.DELIMITER);
|
|
i++;
|
|
}
|
|
printStreamOrWriter.append("\n");
|
|
}
|
|
|
|
@Override // java.lang.Throwable
|
|
@NonNull
|
|
public synchronized Throwable getCause() {
|
|
int i;
|
|
try {
|
|
if (this.cause == null) {
|
|
String property = System.getProperty(SystemProperties.LINE_SEPARATOR);
|
|
if (this.exceptions.size() > 1) {
|
|
IdentityHashMap identityHashMap = new IdentityHashMap();
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("Multiple exceptions (");
|
|
sb.append(this.exceptions.size());
|
|
sb.append(MarkdownConstants.RIGHT_PARENTHESIS);
|
|
sb.append(property);
|
|
for (Throwable th : this.exceptions) {
|
|
int i2 = 0;
|
|
while (true) {
|
|
if (th != null) {
|
|
for (int i3 = 0; i3 < i2; i3++) {
|
|
sb.append(" ");
|
|
}
|
|
sb.append("|-- ");
|
|
sb.append(th.getClass().getCanonicalName());
|
|
sb.append(": ");
|
|
String message = th.getMessage();
|
|
if (message == null || !message.contains(property)) {
|
|
sb.append(message);
|
|
sb.append(property);
|
|
} else {
|
|
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);
|
|
}
|
|
}
|
|
int i5 = 0;
|
|
while (true) {
|
|
i = i2 + 2;
|
|
if (i5 >= i) {
|
|
break;
|
|
}
|
|
sb.append(" ");
|
|
i5++;
|
|
}
|
|
StackTraceElement[] stackTrace = th.getStackTrace();
|
|
if (stackTrace.length > 0) {
|
|
sb.append("at ");
|
|
sb.append(stackTrace[0]);
|
|
sb.append(property);
|
|
}
|
|
if (identityHashMap.containsKey(th)) {
|
|
Throwable cause = th.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);
|
|
}
|
|
} else {
|
|
identityHashMap.put(th, Boolean.TRUE);
|
|
th = th.getCause();
|
|
i2++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.cause = new ExceptionOverview(sb.toString().trim());
|
|
} else {
|
|
this.cause = this.exceptions.get(0);
|
|
}
|
|
}
|
|
} catch (Throwable th2) {
|
|
throw th2;
|
|
}
|
|
return this.cause;
|
|
}
|
|
|
|
@NonNull
|
|
public List<Throwable> getExceptions() {
|
|
return this.exceptions;
|
|
}
|
|
|
|
@Override // java.lang.Throwable
|
|
@NonNull
|
|
public String getMessage() {
|
|
return this.message;
|
|
}
|
|
|
|
public int size() {
|
|
return this.exceptions.size();
|
|
}
|
|
|
|
@Override // java.lang.Throwable
|
|
public void printStackTrace(PrintStream printStream) {
|
|
printStackTrace(new WrappedPrintStream(printStream));
|
|
}
|
|
|
|
@Override // java.lang.Throwable
|
|
public void printStackTrace(PrintWriter printWriter) {
|
|
printStackTrace(new WrappedPrintWriter(printWriter));
|
|
}
|
|
|
|
@Override // java.lang.Throwable
|
|
public void printStackTrace() {
|
|
printStackTrace(System.err);
|
|
}
|
|
|
|
public CompositeException(@NonNull Throwable... thArr) {
|
|
this(thArr == null ? Collections.singletonList(new NullPointerException("exceptions was null")) : Arrays.asList(thArr));
|
|
}
|
|
}
|