feat(chat): enhance error formatting to include optional error codes for better frontend handling

This commit is contained in:
Anish Sarkar 2026-04-29 21:05:21 +05:30
parent fa6a09197e
commit 901de33684
4 changed files with 97 additions and 58 deletions

View file

@ -1581,7 +1581,8 @@ async def stream_new_chat(
)
else:
yield streaming_service.format_error(
"Premium tokens exhausted. Buy more tokens to continue with this model, or switch to a free model."
"Buy more tokens to continue with this model, or switch to a free model.",
error_code="PREMIUM_QUOTA_EXHAUSTED",
)
yield streaming_service.format_done()
return
@ -2348,7 +2349,8 @@ async def stream_resume_chat(
)
else:
yield streaming_service.format_error(
"Premium tokens exhausted. Buy more tokens to continue with this model, or switch to a free model."
"Buy more tokens to continue with this model, or switch to a free model.",
error_code="PREMIUM_QUOTA_EXHAUSTED",
)
yield streaming_service.format_done()
return