package com.tomastc.anickd.lib;

public enum ErrorCode {
    E100(100, "Import file unsuccessful."),
    E101(101, "Invalid username or password."),
    E102(102, "HATC data not found."),
    E103(103, "DAY Unit data not found."),
    E104(104, "Unmatched Parts content receive."),
    E105(105, "Incorrect checkpoint."),
    E106(106, "Meiji card not matched."),
    E107(107, "Packing check sheet not matched."),
    E108(108, "Schedule not found."),
    E109(109, "Master checkpoint not found."),
    E110(110, "Invalid scanning data format."),
    E111(111, "Invalid settings file."),
    E112(112, "Invalid unlock key."),
    E113(113, "Schedule data not found."),
    E114(114, "Checkpoint data not found."),
    E115(115, "Pending master not found."),
    E116(116, "NG master not found."),
    E117(117, "Case mark not matched."),
    E118(118, "Contents label not matched."),
    E119(119, "Packing quantity not matched."),
    E120(120, "Duplicated scan contents label."),
    E121(121, "Packing the finished contents."),
    E122(122, "Not permitted user."),
    E123(123, "Packing item not found."),
    E124(124, "Item cut part."),
    E201(201, "Meiji card not found."),
    E202(202, "Packing methods file not found."),
    E203(203, "Invalid working process step."),
    E300(300, "Cannot connect to web service."),
    E301(301, "Internal error on web server."),
    E302(302, "Web server unreachable."),
    E303(303, "No handheld activated.");
    private final int id;
    private final String det;

    ErrorCode(final int id, final String det) {
        this.id = id;
        this.det = det;
    }

    public int getId() {
        return id;
    }

    public String getDet() { return det; }

    @Override
    public String toString() {
        return String.format("%s[Code:%d]", det, id);
    }

    public static ErrorCode fromId(final int id) {
        for (ErrorCode e : ErrorCode.values()) {
            if (e.id == id) {
                return e;
            }
        }
        return null;
    }
}
