Skip to content

Commit 70a4d6c

Browse files
committed
improved error handling
1 parent dcfed55 commit 70a4d6c

File tree

1 file changed

+10
-11
lines changed
  • livekit-plugins/livekit-plugins-google/livekit/plugins/google

1 file changed

+10
-11
lines changed

livekit-plugins/livekit-plugins-google/livekit/plugins/google/stt.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -304,21 +304,20 @@ async def input_generator():
304304

305305
await self._run_stream(stream)
306306
except (Aborted, Exception) as e:
307-
error_message = (
308-
"google stt connection aborted"
309-
if isinstance(e, Aborted)
310-
else "google stt connection error"
311-
)
312-
logger.error(
313-
f"{error_message}. Failed after {retry_count}/{max_retry} retries."
314-
if retry_count >= max_retry
315-
else error_message,
316-
exc_info=e if retry_count >= max_retry else None,
317-
)
307+
error_type = "Aborted" if isinstance(e, Aborted) else "Error"
308+
318309
if retry_count >= max_retry:
310+
logger.error(
311+
f"Failed to connect to Google STT after {max_retry} tries due to {error_type}",
312+
exc_info=e,
313+
)
319314
break
320315

321316
retry_delay = min(retry_count * 2, 5) # max 5s
317+
logger.warning(
318+
f"Google STT connection {error_type.lower()} (attempt {retry_count}/{max_retry}), retrying in {retry_delay}s",
319+
exc_info=e,
320+
)
322321
retry_count += 1
323322
await asyncio.sleep(retry_delay)
324323

0 commit comments

Comments
 (0)