fix: [language] catch libretranslate exception

dev
terrtia 2024-02-05 14:19:42 +01:00
parent aa56e71631
commit 4c1d058e6d
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
1 changed files with 5 additions and 2 deletions

View File

@ -349,9 +349,12 @@ class LanguagesDetector:
try:
# [{"confidence": 0.6, "language": "en"}]
resp = self.lt.detect(content)
except: # TODO ERROR MESSAGE
resp = []
except Exception as e: # TODO ERROR MESSAGE
raise Exception(f'libretranslate error: {e}')
# resp = []
if resp:
if isinstance(resp, dict):
raise Exception(f'libretranslate error {resp}')
for language in resp:
if language.confidence >= self.min_probability:
languages.append(language)