package okhttp3.internal.cache;

import h.c;
import h.g;
import h.r;
import java.io.IOException;

/* JADX INFO: loaded from: classes.dex */
class FaultHidingSink extends g {
    private boolean hasErrors;

    FaultHidingSink(r rVar) {
        super(rVar);
    }

    @Override // h.g, h.r, java.io.Closeable, java.lang.AutoCloseable
    public void close() throws IOException {
        if (this.hasErrors) {
            return;
        }
        try {
            super.close();
        } catch (IOException e2) {
            this.hasErrors = true;
            onException(e2);
        }
    }

    @Override // h.g, h.r, java.io.Flushable
    public void flush() throws IOException {
        if (this.hasErrors) {
            return;
        }
        try {
            super.flush();
        } catch (IOException e2) {
            this.hasErrors = true;
            onException(e2);
        }
    }

    protected void onException(IOException iOException) {
    }

    @Override // h.g, h.r
    public void write(c cVar, long j2) throws IOException {
        if (this.hasErrors) {
            cVar.skip(j2);
            return;
        }
        try {
            super.write(cVar, j2);
        } catch (IOException e2) {
            this.hasErrors = true;
            onException(e2);
        }
    }
}
