package d8; import android.util.Log; import java.io.IOException; import n9.a0; import n9.g; import n9.g0; import n9.h; import n9.h0; import x9.i; import x9.n; import x9.v; /* loaded from: classes2.dex */ final class d implements d8.b { /* renamed from: c, reason: collision with root package name */ private static final String f9170c = "d"; /* renamed from: a, reason: collision with root package name */ private final e8.a f9171a; /* renamed from: b, reason: collision with root package name */ private g f9172b; class a implements h { /* renamed from: a, reason: collision with root package name */ final /* synthetic */ d8.c f9173a; a(d8.c cVar) { this.f9173a = cVar; } private void c(Throwable th) { try { this.f9173a.a(d.this, th); } catch (Throwable th2) { Log.w(d.f9170c, "Error on executing callback", th2); } } @Override // n9.h public void a(g gVar, g0 g0Var) { try { d dVar = d.this; try { this.f9173a.b(d.this, dVar.f(g0Var, dVar.f9171a)); } catch (Throwable th) { Log.w(d.f9170c, "Error on excuting callback", th); } } catch (Throwable th2) { c(th2); } } @Override // n9.h public void b(g gVar, IOException iOException) { c(iOException); } } static final class b extends h0 { /* renamed from: a, reason: collision with root package name */ private final h0 f9175a; /* renamed from: b, reason: collision with root package name */ IOException f9176b; class a extends i { a(v vVar) { super(vVar); } @Override // x9.i, x9.v public long s0(x9.c cVar, long j10) { try { return super.s0(cVar, j10); } catch (IOException e10) { b.this.f9176b = e10; throw e10; } } } b(h0 h0Var) { this.f9175a = h0Var; } @Override // n9.h0 public long G() { return this.f9175a.G(); } @Override // n9.h0 public a0 I() { return this.f9175a.I(); } @Override // n9.h0 public x9.e S() { return n.c(new a(this.f9175a.S())); } void a0() { IOException iOException = this.f9176b; if (iOException != null) { throw iOException; } } @Override // n9.h0, java.io.Closeable, java.lang.AutoCloseable public void close() { this.f9175a.close(); } } static final class c extends h0 { /* renamed from: a, reason: collision with root package name */ private final a0 f9178a; /* renamed from: b, reason: collision with root package name */ private final long f9179b; c(a0 a0Var, long j10) { this.f9178a = a0Var; this.f9179b = j10; } @Override // n9.h0 public long G() { return this.f9179b; } @Override // n9.h0 public a0 I() { return this.f9178a; } @Override // n9.h0 public x9.e S() { throw new IllegalStateException("Cannot read raw response body of a converted body."); } } d(g gVar, e8.a aVar) { this.f9172b = gVar; this.f9171a = aVar; } /* JADX INFO: Access modifiers changed from: private */ public e f(g0 g0Var, e8.a aVar) { h0 c10 = g0Var.c(); g0 c11 = g0Var.a0().b(new c(c10.I(), c10.G())).c(); int G = c11.G(); if (G < 200 || G >= 300) { try { x9.c cVar = new x9.c(); c10.S().e0(cVar); return e.c(h0.O(c10.I(), c10.G(), cVar), c11); } finally { c10.close(); } } if (G == 204 || G == 205) { c10.close(); return e.g(null, c11); } b bVar = new b(c10); try { return e.g(aVar.a(bVar), c11); } catch (RuntimeException e10) { bVar.a0(); throw e10; } } @Override // d8.b public e c() { g gVar; synchronized (this) { gVar = this.f9172b; } return f(gVar.c(), this.f9171a); } @Override // d8.b public void d(d8.c cVar) { this.f9172b.G(new a(cVar)); } }