From dad14e60eb489d680386a62cfaa6e57130c57538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 29 May 2024 16:03:08 +0800 Subject: [PATCH] issues/774 --- LunaTranslator/LunaTranslator/translator/gemini.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/LunaTranslator/LunaTranslator/translator/gemini.py b/LunaTranslator/LunaTranslator/translator/gemini.py index f67d8b11..032a48d7 100644 --- a/LunaTranslator/LunaTranslator/translator/gemini.py +++ b/LunaTranslator/LunaTranslator/translator/gemini.py @@ -54,7 +54,11 @@ class TS(basetrans): ], }, verify=False, - ).json() + ) + try: + res = res.json() + except: + raise Exception(res.text) try: line = res["candidates"][0]["content"]["parts"][0]["text"] return line