7673edb04e
- ClientAuthErrorWrapper 构造时 super(JSON.stringify(error)):结构化拒绝在上报事件里是变体名与载荷,不再落成未知客户端错误 - errorReporting 注释同步:载体 message 已带载荷,Tauri 缺陷抛出的真 Error 仍优先用其自身 message/stack
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import type { ClientAuthError } from './generated/ClientAuthError';
|
|
|
|
/**
|
|
* 错误上报上下文:`source` 是错误池的一级维度,`action` / `page` 用于细分指纹。
|
|
*
|
|
* 含义与 [`captureClientError`](./errorReporting.ts) 的入参完全一致。
|
|
*/
|
|
export type ClientErrorReportContext = {
|
|
source: string;
|
|
action?: string;
|
|
page?: string;
|
|
};
|
|
|
|
/**
|
|
* 认证命令失败的 JS 侧载体:`error` 就是 Rust 的结构化拒绝(ts-rs 生成的 `ClientAuthError`
|
|
* 判别联合)。
|
|
*
|
|
* 构造时把整份载荷 `JSON.stringify` 进 `Error.message`:结构化拒绝是普通对象,序列化后
|
|
* 上报事件拿到的是机器事实(变体名与载荷),而不是 `[object Object]`;不读任何变体字段、
|
|
* 不拼用户文案、不注入 `source` / `action`。分流只看类型化的变体,
|
|
* **不要用文案判断**;上报上下文由调用 `captureClientError` 时的显式入参决定。
|
|
*
|
|
* Tauri 缺陷抛出的真 `Error` 序列化只有 `{}`,但上报链路对真 `Error` 优先用其自身
|
|
* message/stack,不受影响。
|
|
*/
|
|
export class ClientAuthErrorWrapper extends Error {
|
|
readonly error: ClientAuthError;
|
|
|
|
constructor(error: ClientAuthError) {
|
|
super(JSON.stringify(error));
|
|
this.name = 'ClientAuthErrorWrapper';
|
|
this.error = error;
|
|
}
|
|
}
|