Skip to content

错误码段 ​

1. 编码规则 ​

错误码为 10 位数字:类型(1) + 系统(3) + 模块(3) + 错误码(3),例如 1002000011。

  • 类型:1 = 业务异常。
  • 系统:固定占位,当前为 002。
  • 模块:由 ServiceErrorCodeRange 统一分配,模块之间不得重叠。
  • 错误码:模块内部自增。

2. 已分配区段 ​

模块区间(段内前缀)
infra1-001-000-000 起
system1-002-000-000 起
report1-003-000-000 起
member1-004-000-000 起
mp1-006-000-000 起
pay1-007-000-000 起
product1-008-000-000 起
bpm1-009-000-000 起
trade1-011-000-000 起
promotion1-013-000-000 起
crm1-020-000-000 起
ai1-022-000-000 起

新增模块前先在本表登记,再写 ErrorCodeConstants,否则会与既有模块冲突。

3. 使用方式 ​

  1. 模块内定义 ErrorCodeConstants,每个错误码一个常量。
  2. 抛 ServiceException,用 ServiceExceptionUtil.exception(...) 构造。
  3. 全局异常处理器把 ErrorCode 渲染为 CommonResult.code/message。
  4. 前端按 code 做本地化提示,不解析 message 文案。