package pl.droidsonroids.gif;

import androidx.annotation.NonNull;
import java.io.IOException;
import java.util.Locale;

/* JADX INFO: loaded from: classes3.dex */
public class GifIOException extends IOException {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public static final /* synthetic */ int f32007a = 0;
    private static final long serialVersionUID = 13038402904505L;
    private final String mErrnoMessage;

    @NonNull
    public final GifError reason;

    public GifIOException(int i10, String str) {
        GifError gifError;
        GifError[] gifErrorArrValues = GifError.values();
        int length = gifErrorArrValues.length;
        int i11 = 0;
        while (true) {
            if (i11 >= length) {
                gifError = GifError.UNKNOWN;
                gifError.errorCode = i10;
                break;
            } else {
                gifError = gifErrorArrValues[i11];
                if (gifError.errorCode == i10) {
                    break;
                } else {
                    i11++;
                }
            }
        }
        this.reason = gifError;
        this.mErrnoMessage = str;
    }

    @Override // java.lang.Throwable
    public final String getMessage() {
        if (this.mErrnoMessage == null) {
            GifError gifError = this.reason;
            gifError.getClass();
            return String.format(Locale.ENGLISH, "GifError %d: %s", Integer.valueOf(gifError.errorCode), gifError.description);
        }
        StringBuilder sb = new StringBuilder();
        GifError gifError2 = this.reason;
        gifError2.getClass();
        sb.append(String.format(Locale.ENGLISH, "GifError %d: %s", Integer.valueOf(gifError2.errorCode), gifError2.description));
        sb.append(": ");
        sb.append(this.mErrnoMessage);
        return sb.toString();
    }
}
