From de1982f84ed2acee9d0d632cb8f2e9abe0c2d3b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 1 Sep 2026 19:05:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B6=E7=B4=A7=E9=94=99=E8=AF=AF=E9=87=87?= =?UTF-8?q?=E9=9B=86=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 排除预期四xx认证失败 增加显式 Tauri 诊断调用辅助函数 --- .../src/services/errorReporting.ts | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/apps/ai-game-creator-shell/src/services/errorReporting.ts b/apps/ai-game-creator-shell/src/services/errorReporting.ts index bf828e26e..3592c9fd9 100644 --- a/apps/ai-game-creator-shell/src/services/errorReporting.ts +++ b/apps/ai-game-creator-shell/src/services/errorReporting.ts @@ -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(); 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( + invokeFn: (command: string, args?: Record) => Promise, + command: string, + args?: Record, +) { + try { + return await invokeFn(command, args); + } catch (error) { + void captureClientError(error, { source: 'tauri', action: command }); + throw error; + } +} + function notify() { listeners.forEach((listener) => listener()); }