Piper 的 chooses 刷新与删除检查业务码,保留空成功响应。主保存成功后刷新失败抛出携带已保存版本的 WorkflowSavePartialError;统一 JSON 错误保留可选 EkbError.details。 workflow save 在部分成功时返回非零与恢复信息,--in-place 仍同步已保存版本;新增带写确认的 refresh-chooses,仅重试元数据刷新,不重发完整快照。主保存失败不改本地版本。 认证重放保留最终鉴权响应检查(含 HTTP 200 的错误头),最多重放一次,其他 HTTP 错误维持 Ky 语义。补充 SDK、CLI、恢复与重放回归,并更新文档。 验证:bun test 922 通过、0 失败;bun run check、git diff --check 通过。所有业务请求均为离线假接口。
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
export class EkbError extends Error {
|
|
constructor(
|
|
message: string,
|
|
public readonly code: string,
|
|
public readonly status?: number,
|
|
public readonly details?: Record<string, unknown>
|
|
) {
|
|
super(message);
|
|
this.name = "EkbError";
|
|
}
|
|
}
|
|
|
|
export class NotLoggedInError extends EkbError {
|
|
constructor(message = "No corp selected") {
|
|
super(message, "NOT_LOGGED_IN", 401);
|
|
this.name = "NotLoggedInError";
|
|
}
|
|
}
|
|
|
|
export class AuthenticationError extends EkbError {
|
|
constructor(message = "Authentication failed") {
|
|
super(message, "AUTH_FAILED", 401);
|
|
this.name = "AuthenticationError";
|
|
}
|
|
}
|
|
|
|
export class PermissionError extends EkbError {
|
|
constructor(message = "Permission denied") {
|
|
super(message, "FORBIDDEN", 403);
|
|
this.name = "PermissionError";
|
|
}
|
|
}
|
|
|
|
export class NotFoundError extends EkbError {
|
|
constructor(message: string, code = "NOT_FOUND") {
|
|
super(message, code, 404);
|
|
this.name = "NotFoundError";
|
|
}
|
|
}
|
|
|
|
export class ValidationError extends EkbError {
|
|
constructor(message: string, code = "VALIDATION_ERROR") {
|
|
super(message, code, 400);
|
|
this.name = "ValidationError";
|
|
}
|
|
}
|
|
|
|
export class BusinessError extends EkbError {
|
|
constructor(message: string, code = "BUSINESS_ERROR", status = 400) {
|
|
super(message, code, status);
|
|
this.name = "BusinessError";
|
|
}
|
|
}
|
|
|
|
export class EkbApiError extends EkbError {
|
|
constructor(message: string, code = "API_ERROR", status = 500) {
|
|
super(message, code, status);
|
|
this.name = "EkbApiError";
|
|
}
|
|
}
|
|
|
|
|