Catch JSONDecodeError. - gopherbay - piratebay gopher interface
(HTM) git clone git://bitreich.org/gopherbay git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/gopherbay
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Tags
(DIR) README
(DIR) LICENSE
---
(DIR) commit d67dcf9f4ec398b19db69dd3cb0ec1cc3fc4f3db
(DIR) parent aaf9dc8c08e7c8eb5f8244a5bb2677de3e649f2d
(HTM) Author: Christoph Lohmann <20h@r-36.net>
Date: Sun, 18 Sep 2022 19:22:38 +0200
Catch JSONDecodeError.
Diffstat:
M q.dcgi | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
(DIR) diff --git a/q.dcgi b/q.dcgi
@@ -2,6 +2,7 @@
# Beerware License, parazyd <parazyd@dyne.org>
from json import loads
+from json.decoder import JSONDecodeError
from sys import argv
from time import strftime, gmtime
from urllib.parse import quote
@@ -139,7 +140,11 @@ def q(_argv):
print("Internal error")
return
- jsondata = loads(data)
+ try:
+ jsondata = loads(data)
+ except JSONDecodeError:
+ print("JSON error from imdb")
+ return
print("\n[7|Search again.|/q.dcgi?|server|port]")