refactor(errors): unify EkbError hierarchy across domains and structured CLI error classification
This commit is contained in:
1 parent
2b220bc5d9
commit
c15d622ba2
8 files changed
+89
-40
No files matched your search
@@ -5,6 +5,7 @@ import {
|
||||
getCorpStaffId,
|
||||
getCorpStaffName,
|
||||
} from "./types.js";
|
||||
import { NotFoundError, NotLoggedInError, ValidationError } from "../errors.js";
|
||||
import { saveGlobalConfig } from "./loader.js";
|
||||
|
||||
export interface CorpSummary {
|
||||
@@ -44,11 +45,11 @@ export function resolveCorpConfig(
|
||||
corp = corps.find((item) => getCorpPhysicalId(item) === selectedCorpId);
|
||||
}
|
||||
if (corp) return corp;
|
||||
throw new Error(`未找到企业或身份标识为 [${selectedCorpId}] 的企业配置`);
|
||||
throw new NotFoundError(`未找到企业或身份标识为 [${selectedCorpId}] 的企业配置`);
|
||||
}
|
||||
|
||||
if (!options.stateful) {
|
||||
throw new Error(
|
||||
throw new ValidationError(
|
||||
"当前处于无状态模式 (Stateless Mode)。执行企业级操作必须显式指定 --corp <corpId>。\n" +
|
||||
"如需设置默认企业,可执行 `hose-use config mode stateful` 切换为有状态模式。"
|
||||
);
|
||||
@@ -58,7 +59,7 @@ export function resolveCorpConfig(
|
||||
if (firstCorp) return firstCorp;
|
||||
|
||||
const hintDirs = candidateDirs?.length ? ` (已检索路径: ${candidateDirs.join(", ")})` : "";
|
||||
throw new Error(`未找到任何企业配置。请先运行 'hose-use auth login' 登录或添加企业配置${hintDirs}。`);
|
||||
throw new NotLoggedInError(`未找到任何企业配置。请先运行 'hose-use auth login' 登录或添加企业配置${hintDirs}。`);
|
||||
}
|
||||
|
||||
export class CorpContext {
|
||||
|
||||
Reference in new issue
Block a user