{"version":3,"sources":["../src/exception.ts"],"sourcesContent":["import { CustomError } from 'ts-custom-error'\nimport type { ExceptionDetail } from './exception-detail.js'\n\n/**\n * Exception 构造函数的配置对象\n */\nexport interface ExceptionOptions {\n  /** 错误消息 */\n  message: string\n  /** 错误类别 */\n  category: number\n  /** 模块 ID */\n  moduleId: number\n  /** 序列 ID */\n  sequenceId: number\n  /** 错误详情（可选，单个或数组） */\n  details?: ExceptionDetail | ExceptionDetail[]\n}\n\n/**\n * 业务异常基类\n *\n * 继承自 ts-custom-error 的 CustomError，提供标准化的异常处理机制。\n * 管理错误类别、模块 ID、序列 ID 和详细错误信息。\n *\n * 不包含 systemId 和 code，由业务系统继承后提供。\n * 这样设计使得二方包可以直接使用，业务系统可以扩展添加 systemId。\n *\n * @example\n * ```typescript\n * class ValidationException extends Exception {\n *   constructor(message: string, details: ExceptionDetail | ExceptionDetail[]) {\n *     super({ message, category: ErrorCategory.VALIDATION, moduleId: 1, sequenceId: 1, details })\n *   }\n * }\n * ```\n */\nexport class Exception extends CustomError {\n  /** 错误类别 */\n  readonly category: number\n  /** 模块 ID */\n  readonly moduleId: number\n  /** 序列 ID */\n  readonly sequenceId: number\n  /** 错误详情列表 */\n  readonly details: readonly ExceptionDetail[]\n\n  /**\n   * 创建异常实例\n   *\n   * @param config - 异常配置对象\n   *\n   * @example\n   * ```typescript\n   * new Exception({\n   *   message: 'Validation failed',\n   *   category: ErrorCategory.VALIDATION,\n   *   moduleId: 1,\n   *   sequenceId: 1,\n   *   details\n   * })\n   * ```\n   */\n  constructor(config: ExceptionOptions) {\n    super(config.message)\n\n    this.category = config.category\n    this.moduleId = config.moduleId\n    this.sequenceId = config.sequenceId\n    this.details = config.details\n      ? Array.isArray(config.details)\n        ? config.details\n        : [config.details]\n      : []\n  }\n}\n"],"mappings":";;;;;AAAA,SAAS,mBAAmB;AAqCrB,IAAM,YAAN,cAAwB,YAAY;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BzC,YAAY,QAA0B;AACpC,UAAM,OAAO,OAAO;AAzBtB;AAAA,wBAAS;AAET;AAAA,wBAAS;AAET;AAAA,wBAAS;AAET;AAAA,wBAAS;AAqBP,SAAK,WAAW,OAAO;AACvB,SAAK,WAAW,OAAO;AACvB,SAAK,aAAa,OAAO;AACzB,SAAK,UAAU,OAAO,UAClB,MAAM,QAAQ,OAAO,OAAO,IAC1B,OAAO,UACP,CAAC,OAAO,OAAO,IACjB,CAAC;AAAA,EACP;AACF;","names":[]}