From 4c1d058e6d3bdd947b4ce27d28f15c61a8dd8c2c Mon Sep 17 00:00:00 2001 From: terrtia Date: Mon, 5 Feb 2024 14:19:42 +0100 Subject: [PATCH] fix: [language] catch libretranslate exception --- bin/lib/Language.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/lib/Language.py b/bin/lib/Language.py index 041b0169..8052bf28 100755 --- a/bin/lib/Language.py +++ b/bin/lib/Language.py @@ -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)