feat(errors): add centralized exception handling

This commit is contained in:
2026-07-03 12:55:45 +08:00
parent e852fb62e9
commit 65d972fbb4
20 changed files with 492 additions and 70 deletions
+2 -4
View File
@@ -5,10 +5,8 @@
* 集中到这里。HTTP 拦截器(`http_client.ts`)已经对非 2xx 响应抛 `ApiError`
* 本工具处理第二种失败:2xx 但 `success: false` 的 envelope。
*
* 行为升级:失败时抛 `ApiError``ApiError extends Error`),而不是裸 `Error`。
* 这样调用方在 `Result.err` 内能 `instanceof ApiError` 检查 `.code` / `.status`。
*
*
* 失败时抛 `ApiError`,让底层保留 HTTP/API 上下文;进入仓库层 `Result`
* 后会被 `ExceptionHandler` 统一收敛为应用可消费的 `{ code, message }`。
*/
import { ApiError, ErrorCode } from "./api_result";