package defpackage;

import androidx.media3.container.NalUnitUtil;
import java.io.IOException;
import java.util.concurrent.CancellationException;
import kotlin.Metadata;

/* JADX INFO: loaded from: classes3.dex */
@Metadata(d1 = {"\u0000\n\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\b\u0000\u0018\u00002\u00020\u0001¨\u0006\u0002"}, d2 = {"Lb21;", "", "ktor-io"}, k = 1, mv = {2, 0, 0}, xi = NalUnitUtil.H265_NAL_UNIT_TYPE_UNSPECIFIED)
public final class b21 {
    public final Throwable a;

    /* JADX WARN: Multi-variable type inference failed */
    public b21(Throwable th) {
        Throwable iOException;
        if (th == 0) {
            iOException = null;
        } else if (th instanceof CancellationException) {
            if (th instanceof aj1) {
                iOException = ((aj1) th).a();
            } else {
                String message = ((CancellationException) th).getMessage();
                iOException = er2.a(message == null ? "Channel was cancelled" : message, th);
            }
        } else if ((th instanceof IOException) && (th instanceof aj1)) {
            iOException = ((aj1) th).a();
        } else {
            String message2 = th.getMessage();
            iOException = new IOException(message2 == null ? "Channel was closed" : message2, th);
        }
        this.a = iOException;
    }

    /* JADX WARN: Multi-variable type inference failed */
    public final Throwable a() {
        Throwable thA;
        Throwable th = this.a;
        if (th == 0) {
            return null;
        }
        return th instanceof IOException ? th instanceof aj1 ? ((aj1) th).a() : new IOException(((IOException) th).getMessage(), th) : (!(th instanceof aj1) || (thA = ((aj1) th).a()) == null) ? er2.a(th.getMessage(), th) : thA;
    }
}
