From: Alexander Vasarab Date: Tue, 2 Feb 2021 06:00:38 +0000 (-0800) Subject: Catch KeyError exception when interpreting json X-Git-Tag: v3.1.1^2~1^2~3 X-Git-Url: https://wylark.com/src/infoex-autowx.git/commitdiff_plain/c3d3cc62e986acac7b4b044eb7958b20e48ab2a1 Catch KeyError exception when interpreting json --- diff --git a/infoex-autowx.py b/infoex-autowx.py index f2be003..9bd77c1 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -473,6 +473,9 @@ def get_mesowest_data(begin, end, station): try: observations = json['STATION'][0]['OBSERVATIONS'] + except KeyError: + LOG.error("Unexpected JSON in MesoWest response") + sys.exit(1) except ValueError: LOG.error("Bad JSON in MesoWest response") sys.exit(1)