package com.microservices.common.core.exception;

/**
 * 业务异常
 *
 * @author microservices
 */
public final class NotFoundException extends RuntimeException {
    private static final long serialVersionUID = 1L;

    /**
     * 错误提示
     */
    private String message;

    /**
     * 错误明细，内部调试错误
     * <p>
     * 和 {@link CommonResult#getDetailMessage()} 一致的设计
     */
    private String detailMessage;

    /**
     * 空构造方法，避免反序列化问题
     */
    public NotFoundException() {
    }

    public NotFoundException(String message) {
        this.message = message;
    }

    /**
     * 用户可传入异常消息及参数列表，系统将根据String.format形式组装异常消息
     *
     * @param message
     * @param params
     */
    public NotFoundException(String message, Object... params) {
        this.message = String.format(message, params);
    }

    public String getDetailMessage() {
        return detailMessage;
    }

    @Override
    public String getMessage() {
        return message;
    }

    public NotFoundException setMessage(String message) {
        this.message = message;
        return this;
    }

    public NotFoundException setDetailMessage(String detailMessage) {
        this.detailMessage = detailMessage;
        return this;
    }
}