Skip to content

Commit edb04af

Browse files
committed
Better openrouter error handling
1 parent 83ba22a commit edb04af

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/core/Cline.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1227,7 +1227,16 @@ export class Cline extends EventEmitter<ClineEvents> {
12271227
} catch (error) {
12281228
// note that this api_req_failed ask is unique in that we only present this option if the api hasn't streamed any content yet (ie it fails on the first chunk due), as it would allow them to hit a retry button. However if the api failed mid-stream, it could be in any arbitrary state where some tools may have executed, so that error is handled differently and requires cancelling the task entirely.
12291229
if (alwaysApproveResubmit) {
1230-
const errorMsg = error.error?.metadata?.raw ?? error.message ?? "Unknown error"
1230+
let errorMsg
1231+
1232+
if (error.error?.metadata?.raw) {
1233+
errorMsg = JSON.stringify(error.error.metadata.raw, null, 2)
1234+
} else if (error.message) {
1235+
errorMsg = error.message
1236+
} else {
1237+
errorMsg = "Unknown error"
1238+
}
1239+
12311240
const baseDelay = requestDelaySeconds || 5
12321241
const exponentialDelay = Math.ceil(baseDelay * Math.pow(2, retryAttempt))
12331242
// Wait for the greater of the exponential delay or the rate limit delay

0 commit comments

Comments
 (0)