mirror of https://gitlab.com/bashrc2/epicyon
Catch exception
parent
35219af5ea
commit
c30b32553d
|
@ -214,6 +214,8 @@ def _libretranslate(url: str, text: str,
|
|||
else:
|
||||
url += "translate"
|
||||
|
||||
originalText = text
|
||||
|
||||
# get any links from the text
|
||||
links = getLinksFromContent(text)
|
||||
|
||||
|
@ -236,7 +238,11 @@ def _libretranslate(url: str, text: str,
|
|||
urlParams = parse.urlencode(ltParams)
|
||||
|
||||
req = request.Request(url, data=urlParams.encode())
|
||||
try:
|
||||
response = request.urlopen(req)
|
||||
except BaseException:
|
||||
print('Unaable to translate: ' + text)
|
||||
return originalText
|
||||
|
||||
response_str = response.read().decode()
|
||||
|
||||
|
|
Loading…
Reference in New Issue