From abe6a15b93a32b445c8c430a57e0299f91d6dce8 Mon Sep 17 00:00:00 2001 From: hex2077 Date: Sun, 21 Dec 2025 17:25:18 +0800 Subject: [PATCH] =?UTF-8?q?fix(claude-kiro):=20=E4=BF=AE=E5=A4=8D=E7=A4=BE?= =?UTF-8?q?=E4=BA=A4=E8=AE=A4=E8=AF=81=E6=96=B9=E6=B3=95=E4=B8=8B=E6=9C=AA?= =?UTF-8?q?=E6=A3=80=E6=9F=A5profileArn=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当使用社交认证方法时,添加对profileArn的检查以避免潜在的错误 refactor(ui-manager): 改进console日志的错误处理 增强日志系统对复杂对象和错误的处理能力,避免字符串化时出现异常 --- src/claude/claude-kiro.js | 4 ++-- src/ui-manager.js | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/claude/claude-kiro.js b/src/claude/claude-kiro.js index ad1bd8e..1fb5070 100644 --- a/src/claude/claude-kiro.js +++ b/src/claude/claude-kiro.js @@ -1784,7 +1784,7 @@ async initializeAuth(forceRefresh = false) { origin: KIRO_CONSTANTS.ORIGIN_AI_EDITOR, resourceType: resourceType }); - if (this.authMethod === KIRO_CONSTANTS.AUTH_METHOD_SOCIAL) { + if (this.authMethod === KIRO_CONSTANTS.AUTH_METHOD_SOCIAL && this.profileArn) { params.append('profileArn', this.profileArn); } const fullUrl = `${usageLimitsUrl}?${params.toString()}`; @@ -1828,7 +1828,7 @@ async initializeAuth(forceRefresh = false) { throw refreshError; } } - console.error('[Kiro] Failed to fetch usage limits:', error.message); + console.error('[Kiro] Failed to fetch usage limits:', error.message, error); throw error; } } diff --git a/src/ui-manager.js b/src/ui-manager.js index 87a98cd..3e0f1ef 100644 --- a/src/ui-manager.js +++ b/src/ui-manager.js @@ -1881,7 +1881,17 @@ export function initializeUIManagement() { const originalLog = console.log; console.log = function(...args) { originalLog.apply(console, args); - const message = args.map(arg => typeof arg === 'string' ? arg : JSON.stringify(arg)).join(' '); + const message = args.map(arg => { + if (typeof arg === 'string') return arg; + try { + return JSON.stringify(arg); + } catch (e) { + if (arg instanceof Error) { + return `[Error: ${arg.message}] ${arg.stack || ''}`; + } + return `[Object: ${Object.prototype.toString.call(arg)}] (Circular or too complex to stringify)`; + } + }).join(' '); const logEntry = { timestamp: new Date().toISOString(), level: 'info', @@ -1898,7 +1908,17 @@ export function initializeUIManagement() { const originalError = console.error; console.error = function(...args) { originalError.apply(console, args); - const message = args.map(arg => typeof arg === 'string' ? arg : JSON.stringify(arg)).join(' '); + const message = args.map(arg => { + if (typeof arg === 'string') return arg; + try { + return JSON.stringify(arg); + } catch (e) { + if (arg instanceof Error) { + return `[Error: ${arg.message}] ${arg.stack || ''}`; + } + return `[Object: ${Object.prototype.toString.call(arg)}] (Circular or too complex to stringify)`; + } + }).join(' '); const logEntry = { timestamp: new Date().toISOString(), level: 'error',