using System;

namespace CncService
{
    /// <summary>
    /// 业务异常
    /// Service层抛出此异常，由全局异常过滤器统一捕获并转换为ApiResponse
    /// </summary>
    public class BusinessException : Exception
    {
        /// <summary>业务错误码（非0）</summary>
        public int Code { get; }

        /// <summary>
        /// 创建业务异常
        /// </summary>
        /// <param name="code">错误码，参见 CncModels.Constants.ErrorCode</param>
        /// <param name="message">错误信息，会返回给前端展示</param>
        public BusinessException(int code, string message) : base(message)
        {
            Code = code;
        }
    }
}
