feat(core): 引入统一错误码模型并新增 USERGUIDE

为 issue #1 的公共错误契约建立错误码模型:

- core/src/error_code.rs:ErrorCode(BAT-ERR-<域3位><序号3位>,如 BAT-ERR-300012)
  + 44 个初始码表(覆盖输入/路径安全/网络下载/校验/发布存储/解析/任务RPC/内部
  八域,网络域含代理故障 310001)、ErrorDomain、以及进入 RPC envelope / --json /
  bat-events.jsonl 的统一 ApiError { code, kind, domain, location, message, retryable }。
  location 用稳定的组件·操作标签(不随行号漂移)。
- 新增 USERGUIDE.md:bat 命令、选项(发现/同步/守护/输出)、退出码(含 75=locked)、
  运行时默认值,以及从码表同步的错误码参考(含承载结构与域一览)。

命名遵循国际惯例(英文 kind/domain slug)。码表以 error_code.rs 为准,USERGUIDE
错误码表与之逐条一致。后续各链路报错接入该码表在 issue #1 下推进。

对应 issue #1(错误码模型 + 用户指南)。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-17 03:57:17 -07:00
co-authored by Claude Fable 5
parent 17b86ab9fa
commit 1a25ea58dd
3 changed files with 621 additions and 0 deletions
+2
View File
@@ -17,10 +17,12 @@
pub mod domain;
pub mod error;
pub mod error_code;
pub mod repositories;
pub mod services;
pub use error::{Error, Result};
pub use error_code::{ApiError, ErrorCode, ErrorDomain};
/// Core 版本号
pub const VERSION: &str = env!("CARGO_PKG_VERSION");