package kotlinx.coroutines;

import androidx.media3.container.NalUnitUtil;
import defpackage.cr2;
import defpackage.gj1;
import defpackage.oj1;
import kotlin.Metadata;
import kotlinx.coroutines.CoroutineExceptionHandler;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\u0002\n\u0000¨\u0006\u0000"}, d2 = {"kotlinx-coroutines-core"}, k = 2, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public final class b {
    public static final void a(gj1 gj1Var, Throwable th) {
        try {
            CoroutineExceptionHandler coroutineExceptionHandler = (CoroutineExceptionHandler) gj1Var.cb(CoroutineExceptionHandler.b.a);
            if (coroutineExceptionHandler != null) {
                coroutineExceptionHandler.af();
            } else {
                oj1.a(gj1Var, th);
            }
        } catch (Throwable th2) {
            if (th != th2) {
                RuntimeException runtimeException = new RuntimeException("Exception while trying to handle coroutine exception", th2);
                cr2.a(runtimeException, th);
                th = runtimeException;
            }
            oj1.a(gj1Var, th);
        }
    }
}
