package ru.kirillius.cooler.controller.API;

public enum ErrorCode {
    ERR_UNSUPPORTED_OPERATION(0x0),
    ERR_UNKNOWN_DATA_TYPE(0x1),
    ERR_UNKNOWN_ACTION_TYPE(0x2),
    ERR_INVALID_CHECKSUM(0x3),
    UNKNOWN(0x255);

    private final byte value;

    ErrorCode(int value) {
        this.value = (byte) value;
    }

    public static ErrorCode getByValue(byte value) {
        for (var type : values()) {
            if (type.value == value) return type;
        }
        return UNKNOWN;
    }

    public byte getValue() {
        return value;
    }
}