瀏覽代碼

fix: improve error property extraction from nested response objects (#7669)

- Remove intermediate response extraction to preserve full error structure
- Add fallback to error.response.message and error.response.status
- Stringify error object in logException for better console output
Bee 1 月之前
父節點
當前提交
e22c457d19
共有 2 個文件被更改,包括 4 次插入5 次删除
  1. 3 4
      src/services/error/ClineError.ts
  2. 1 1
      src/services/error/ErrorService.ts

+ 3 - 4
src/services/error/ClineError.ts

@@ -56,14 +56,13 @@ export class ClineError extends Error {
 		public readonly modelId?: string,
 		public readonly providerId?: string,
 	) {
-		const serialized = serializeError(raw)
-		const error = serialized?.response || serialized
+		const error = serializeError(raw)
 
-		const message = error.message || String(error) || error?.cause?.means
+		const message = error.message || error?.response?.message || String(error) || error?.cause?.means
 		super(message)
 
 		// Extract status from multiple possible locations
-		const status = error.status || error.statusCode
+		const status = error.status || error.statusCode || error.response?.status
 		this.modelId = modelId || error.modelId
 		this.providerId = providerId || error.providerId
 

+ 1 - 1
src/services/error/ErrorService.ts

@@ -41,7 +41,7 @@ export class ErrorService {
 
 	public logException(error: Error | ClineError, properties?: Record<string, unknown>): void {
 		this.provider.logException(error, properties)
-		console.error("[ErrorService] Logging exception", error)
+		console.error("[ErrorService] Logging exception", JSON.stringify(error))
 	}
 
 	public logMessage(