fix(cartesia): stop double-yielding ErrorFrame on HTTP non-200

The non-200 branch yielded an ErrorFrame and then raised, which the outer
except caught and yielded a second, less informative "Unknown error" frame.
Return after the yield and fold the status code into the message.
This commit is contained in:
Mark Backman
2026-04-30 09:41:43 -04:00
parent 3e5aabc5f2
commit 21547c8680

View File

@@ -955,8 +955,10 @@ class CartesiaHttpTTSService(TTSService):
async with self._session.post(url, json=payload, headers=headers) as response:
if response.status != 200:
error_text = await response.text()
yield ErrorFrame(error=f"Cartesia API error: {error_text}")
raise Exception(f"Cartesia API returned status {response.status}: {error_text}")
yield ErrorFrame(
error=f"Cartesia API error (status {response.status}): {error_text}"
)
return
audio_data = await response.read()