Skip to content

Commit 8aebd4b

Browse files
Fix access to cleared exception variable in openrouter_client.py (#354)
1 parent 3444d0b commit 8aebd4b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

api/openrouter_client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,23 +320,26 @@ async def content_generator():
320320
yield "Error: No response content from OpenRouter API"
321321

322322
return content_generator()
323-
except aiohttp.ClientError as e_client:
323+
except aiohttp.ClientError as e:
324+
e_client = e
324325
log.error(f"Connection error with OpenRouter API: {str(e_client)}")
325326

326327
# Return a generator that yields the error message
327328
async def connection_error_generator():
328329
yield f"Connection error with OpenRouter API: {str(e_client)}. Please check your internet connection and that the OpenRouter API is accessible."
329330
return connection_error_generator()
330331

331-
except RequestException as e_req:
332+
except RequestException as e:
333+
e_req = e
332334
log.error(f"Error calling OpenRouter API asynchronously: {str(e_req)}")
333335

334336
# Return a generator that yields the error message
335337
async def request_error_generator():
336338
yield f"Error calling OpenRouter API: {str(e_req)}"
337339
return request_error_generator()
338340

339-
except Exception as e_unexp:
341+
except Exception as e:
342+
e_unexp = e
340343
log.error(f"Unexpected error calling OpenRouter API asynchronously: {str(e_unexp)}")
341344

342345
# Return a generator that yields the error message

0 commit comments

Comments
 (0)