mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-13 01:17:17 +01:00
103 lines
3.5 KiB
Java
103 lines
3.5 KiB
Java
package rx.exceptions;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Set;
|
|
import rx.plugins.RxJavaPlugins;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes12.dex */
|
|
public final class OnErrorThrowable extends RuntimeException {
|
|
private static final long serialVersionUID = -569558213262703934L;
|
|
private final boolean hasValue;
|
|
private final Object value;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class OnNextValue extends RuntimeException {
|
|
private static final long serialVersionUID = -3454462756050397899L;
|
|
private final Object value;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static final class Primitives {
|
|
static final Set<Class<?>> INSTANCE = create();
|
|
|
|
private static Set<Class<?>> create() {
|
|
HashSet hashSet = new HashSet();
|
|
hashSet.add(Boolean.class);
|
|
hashSet.add(Character.class);
|
|
hashSet.add(Byte.class);
|
|
hashSet.add(Short.class);
|
|
hashSet.add(Integer.class);
|
|
hashSet.add(Long.class);
|
|
hashSet.add(Float.class);
|
|
hashSet.add(Double.class);
|
|
return hashSet;
|
|
}
|
|
}
|
|
|
|
public OnNextValue(Object obj) {
|
|
super("OnError while emitting onNext value: " + renderValue(obj));
|
|
this.value = obj;
|
|
}
|
|
|
|
public static String renderValue(Object obj) {
|
|
if (obj == null) {
|
|
return "null";
|
|
}
|
|
if (Primitives.INSTANCE.contains(obj.getClass())) {
|
|
return obj.toString();
|
|
}
|
|
if (obj instanceof String) {
|
|
return (String) obj;
|
|
}
|
|
if (obj instanceof Enum) {
|
|
return ((Enum) obj).name();
|
|
}
|
|
String handleOnNextValueRendering = RxJavaPlugins.getInstance().getErrorHandler().handleOnNextValueRendering(obj);
|
|
return handleOnNextValueRendering != null ? handleOnNextValueRendering : obj.getClass().getName().concat(".class");
|
|
}
|
|
|
|
public Object getValue() {
|
|
return this.value;
|
|
}
|
|
}
|
|
|
|
private OnErrorThrowable(Throwable th) {
|
|
super(th);
|
|
this.hasValue = false;
|
|
this.value = null;
|
|
}
|
|
|
|
public static Throwable addValueAsLastCause(Throwable th, Object obj) {
|
|
if (th == null) {
|
|
th = new NullPointerException();
|
|
}
|
|
Throwable finalCause = Exceptions.getFinalCause(th);
|
|
if ((finalCause instanceof OnNextValue) && ((OnNextValue) finalCause).getValue() == obj) {
|
|
return th;
|
|
}
|
|
Exceptions.addCause(th, new OnNextValue(obj));
|
|
return th;
|
|
}
|
|
|
|
public static OnErrorThrowable from(Throwable th) {
|
|
if (th == null) {
|
|
th = new NullPointerException();
|
|
}
|
|
Throwable finalCause = Exceptions.getFinalCause(th);
|
|
return finalCause instanceof OnNextValue ? new OnErrorThrowable(th, ((OnNextValue) finalCause).getValue()) : new OnErrorThrowable(th);
|
|
}
|
|
|
|
public Object getValue() {
|
|
return this.value;
|
|
}
|
|
|
|
public boolean isValueNull() {
|
|
return this.hasValue;
|
|
}
|
|
|
|
private OnErrorThrowable(Throwable th, Object obj) {
|
|
super(th);
|
|
this.hasValue = true;
|
|
this.value = obj;
|
|
}
|
|
}
|