5013f4385f
Project CI / AI game creator shell Rust smoke (pull_request) Successful in 1m50s
Project CI / AI game creator shell Rust crates (pull_request) Successful in 1m9s
Project CI / Backend tests (pull_request) Failing after 16s
Project CI / Frontend tests (pull_request) Successful in 2m3s
Project CI / Repository checks (pull_request) Failing after 14s
Project CI / AI game creator shell web tests (pull_request) Failing after 1m42s
Project CI / Native shell tests (pull_request) Successful in 5m41s
Project CI / AI game creator shell Rust lane 1/2 (pull_request) Successful in 10m10s
Project CI / AI game creator shell Rust lane 2/2 (pull_request) Successful in 11m9s
- 新增 clientActionError.ts:ClientActionError 承载 source/action/page 上下文与 cause - 新增 clientAuthError.ts:isClientAuthError 形状读取 + clientAuthErrorKind 的 input/session/fault 分类 + clientAuthErrorNotice 文案 - captureClientError 解包 ClientActionError 的上下文,并优先使用 cause 的栈信息 - getClientAuthErrorMessage 认识结构化拒绝,非 Error 形状不再字符串化成 [object Object] - 新增 clientAuthError.test.ts,并在 errorReporting.test.ts 用解包用例替换 shouldCaptureClientError 用例
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
/**
|
|
* 错误上报上下文:`source` 是错误池的一级维度,`action` / `page` 用于细分指纹。
|
|
*
|
|
* 含义与 [`captureClientError`](./errorReporting.ts) 的入参完全一致。
|
|
*/
|
|
export type ClientErrorReportContext = {
|
|
source: string;
|
|
action?: string;
|
|
page?: string;
|
|
};
|
|
|
|
/**
|
|
* 调用方判定「这是真故障 / 认不出」时的统一载体:`message` 是可展示文案,`context` 决定错误池的
|
|
* 指纹维度,`cause` 保留原始拒绝值(Rust 的结构化 `ClientAuthError`、裸字符串或 `Error`)。
|
|
*
|
|
* 分流只看类型化的变体,**不要用文案判断**。`captureClientError` 用 `instanceof` 解包
|
|
* `context` 与 `cause`,所以它与显式调用 `captureClientError(error, context)` 的指纹、展示字段一致;
|
|
* 需要"带上文继续抛出"的调用方也可以直接 `throw` 它。
|
|
*/
|
|
export class ClientActionError extends Error {
|
|
readonly context: ClientErrorReportContext;
|
|
|
|
constructor(
|
|
message: string,
|
|
context: ClientErrorReportContext,
|
|
cause?: unknown,
|
|
) {
|
|
super(message, { cause });
|
|
this.name = 'ClientActionError';
|
|
this.context = context;
|
|
}
|
|
}
|