收紧错误采集条件

排除预期四xx认证失败

增加显式 Tauri 诊断调用辅助函数
This commit is contained in:
2026-09-01 19:05:08 +08:00
parent ba74c1af30
commit de1982f84e
@@ -17,12 +17,33 @@ export type DiagnosticLogFile = { name: string; content: string };
type WebviewLogLevel = 'debug' | 'info' | 'warn' | 'error' | 'log';
export const OPEN_ERROR_REPORT_EVENT = 'agc-open-error-report';
const pending = new Map<string, ClientErrorEvent>();
const listeners = new Set<() => void>();
const MAX_EVENTS = 100;
export function shouldCaptureClientError(error: unknown) {
if (!error || typeof error !== 'object') return true;
const candidate = error as { status?: unknown; networkError?: unknown };
if (candidate.networkError === true) return true;
if (typeof candidate.status === 'number') {
return candidate.status === 408 || candidate.status >= 500;
}
return true;
}
export async function invokeDiagnostic<T>(
invokeFn: (command: string, args?: Record<string, unknown>) => Promise<T>,
command: string,
args?: Record<string, unknown>,
) {
try {
return await invokeFn(command, args);
} catch (error) {
void captureClientError(error, { source: 'tauri', action: command });
throw error;
}
}
function notify() {
listeners.forEach((listener) => listener());
}