package d2;

/* JADX INFO: compiled from: CoroutineExceptionHandler.kt */
/* JADX INFO: loaded from: classes.dex */
public final class y {
    public static final void a(n1.f fVar, Throwable th) {
        try {
            v vVar = (v) fVar.get(v.f4533b);
            if (vVar == null) {
                x.a(fVar, th);
            } else {
                vVar.handleException(fVar, th);
            }
        } catch (Throwable th2) {
            x.a(fVar, b(th, th2));
        }
    }

    public static final Throwable b(Throwable th, Throwable th2) {
        if (th == th2) {
            return th;
        }
        RuntimeException runtimeException = new RuntimeException("Exception while trying to handle coroutine exception", th2);
        k1.b.a(runtimeException, th);
        return runtimeException;
    }
}
