Better OpenRouter error handling

This commit is contained in:
Matt Rubens 2025-02-26 13:52:38 -05:00
parent 3860abf855
commit d7266be3fe
2 changed files with 6 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
"roo-cline": patch
---
Better OpenRouter error handling

View file

@ -1010,7 +1010,7 @@ export class Cline {
} catch (error) {
// 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.
if (alwaysApproveResubmit) {
const errorMsg = error.message ?? "Unknown error"
const errorMsg = error.error?.metadata?.raw ?? error.message ?? "Unknown error"
const baseDelay = requestDelaySeconds || 5
const exponentialDelay = Math.ceil(baseDelay * Math.pow(2, retryAttempt))
// Wait for the greater of the exponential delay or the rate limit delay