package rx.exceptions; import j0.o.o; import java.io.Serializable; import java.util.HashSet; import java.util.Objects; import java.util.Set; public final class OnErrorThrowable extends RuntimeException { private static final long serialVersionUID = -569558213262703934L; private final boolean hasValue; private final Object value; public static class OnNextValue extends RuntimeException { private static final long serialVersionUID = -3454462756050397899L; private final Object value; public static final class a { public static final Set> a; static { 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); a = hashSet; } } /* JADX WARNING: Illegal instructions before constructor call */ public OnNextValue(Object obj) { super(r0.toString()); String str; StringBuilder K = c.d.b.a.a.K("OnError while emitting onNext value: "); if (obj == null) { str = "null"; } else if (a.a.contains(obj.getClass())) { str = obj.toString(); } else if (obj instanceof String) { str = (String) obj; } else if (obj instanceof Enum) { str = ((Enum) obj).name(); } else { Objects.requireNonNull(o.a.b()); str = obj.getClass().getName() + ".class"; } K.append(str); if (!(obj instanceof Serializable)) { try { obj = String.valueOf(obj); } catch (Throwable th) { obj = th.getMessage(); } } this.value = obj; } public Object a() { return this.value; } } public static Throwable a(Throwable th, Object obj) { if (th == null) { th = new NullPointerException(); } int i = 0; int i2 = 0; Throwable th2 = th; while (true) { if (th2.getCause() == null) { break; } int i3 = i2 + 1; if (i2 >= 25) { th2 = new RuntimeException("Stack too deep to get final cause"); break; } th2 = th2.getCause(); i2 = i3; } if ((th2 instanceof OnNextValue) && ((OnNextValue) th2).a() == obj) { return th; } OnNextValue onNextValue = new OnNextValue(obj); HashSet hashSet = new HashSet(); Throwable th3 = th; while (true) { if (th3.getCause() != null) { int i4 = i + 1; if (i >= 25) { break; } th3 = th3.getCause(); if (!hashSet.contains(th3.getCause())) { hashSet.add(th3.getCause()); i = i4; } } try { th3.initCause(onNextValue); break; } catch (Throwable unused) { } } return th; } }