package g.e.b;

import java.io.IOException;
import java.io.StringReader;
import java.util.Objects;

/* JADX INFO: loaded from: classes.dex */
public final class t {
    public static o a(g.e.b.i0.a aVar) {
        boolean z2 = aVar.f4169m;
        aVar.f4169m = true;
        try {
            try {
                try {
                    return g.e.a.a.a.x(aVar);
                } catch (StackOverflowError e2) {
                    throw new s("Failed parsing JSON source: " + aVar + " to Json", e2);
                }
            } catch (OutOfMemoryError e3) {
                throw new s("Failed parsing JSON source: " + aVar + " to Json", e3);
            }
        } finally {
            aVar.f4169m = z2;
        }
    }

    public static o b(String str) {
        try {
            g.e.b.i0.a aVar = new g.e.b.i0.a(new StringReader(str));
            o oVarA = a(aVar);
            Objects.requireNonNull(oVarA);
            if (!(oVarA instanceof q) && aVar.I() != g.e.b.i0.b.END_DOCUMENT) {
                throw new x("Did not consume the entire document.");
            }
            return oVarA;
        } catch (g.e.b.i0.d e2) {
            throw new x(e2);
        } catch (IOException e3) {
            throw new p(e3);
        } catch (NumberFormatException e4) {
            throw new x(e4);
        }
    }
}
