package eu.jonahbauer.wizard.server;

import eu.jonahbauer.wizard.common.messages.server.NackMessage;
import org.intellij.lang.annotations.MagicConstant;

public class NackException extends RuntimeException {
    private final int code;

    public NackException(@MagicConstant(valuesFromClass = NackMessage.class) int code, String message) {
        super(message);
        this.code = code;
    }

    @MagicConstant(valuesFromClass = NackMessage.class)
    public int getCode() {
        return code;
    }

    public NackMessage toMessage() {
        return new NackMessage(code, getMessage());
    }
}
