Skip to content

Commit

Permalink
fix: [language] catch libretranslate exception
Browse files Browse the repository at this point in the history
  • Loading branch information
Terrtia committed Feb 5, 2024
1 parent aa56e71 commit 4c1d058
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions bin/lib/Language.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,12 @@ def detect_libretranslate(self, content):
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)
Expand Down

0 comments on commit 4c1d058

Please sign in to comment.