package g.a;

/* JADX INFO: compiled from: CoroutineExceptionHandler.kt */
/* JADX INFO: loaded from: classes.dex */
public final class e0 {
    public static final void a(f.w.g gVar, Throwable th) {
        try {
            c0 c0Var = (c0) gVar.get(c0.f4015d);
            if (c0Var != null) {
                c0Var.handleException(gVar, th);
            } else {
                d0.a(gVar, th);
            }
        } catch (Throwable th2) {
            d0.a(gVar, 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);
        f.b.a(runtimeException, th);
        return runtimeException;
    }
}
