package coil.disk;

import J4.c;
import java.io.EOFException;
import java.io.IOException;
import p5.C2740j;
import p5.N;
import p5.v;

/* JADX INFO: loaded from: classes.dex */
public final class FaultHidingSink extends v {
    private boolean hasErrors;
    private final c onException;

    public FaultHidingSink(N n6, c cVar) {
        super(n6);
        this.onException = cVar;
    }

    @Override // p5.v, p5.N, java.io.Closeable, java.lang.AutoCloseable
    public void close() {
        try {
            super.close();
        } catch (IOException e6) {
            this.hasErrors = true;
            this.onException.invoke(e6);
        }
    }

    @Override // p5.v, p5.N, java.io.Flushable
    public void flush() {
        try {
            super.flush();
        } catch (IOException e6) {
            this.hasErrors = true;
            this.onException.invoke(e6);
        }
    }

    @Override // p5.v, p5.N
    public void write(C2740j c2740j, long j4) throws EOFException {
        if (this.hasErrors) {
            c2740j.J(j4);
            return;
        }
        try {
            super.write(c2740j, j4);
        } catch (IOException e6) {
            this.hasErrors = true;
            this.onException.invoke(e6);
        }
    }
}
