package eu.jonahbauer.wizard.server;

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

public class NackException extends RuntimeException {
    @Getter(onMethod = @__({@MagicConstant(valuesFromClass = NackMessage.class)}))
    private final int code;

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

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