From f6ec08d2525c2418d14fecaaab1c78e15e1c1b21 Mon Sep 17 00:00:00 2001 From: Alexander Vasarab Date: Mon, 1 Feb 2021 22:11:38 -0800 Subject: [PATCH] Catch a few more exceptions, and Pylint fixes --- infoex-autowx.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/infoex-autowx.py b/infoex-autowx.py index b979287..a68d778 100755 --- a/infoex-autowx.py +++ b/infoex-autowx.py @@ -474,11 +474,19 @@ def get_mesowest_data(begin, end, station): try: observations = json['STATION'][0]['OBSERVATIONS'] - except KeyError: - LOG.error("Unexpected JSON in MesoWest response") + except KeyError as exc: + LOG.error("Unexpected JSON in MesoWest response: '%s'", exc) sys.exit(1) - except ValueError: - LOG.error("Bad JSON in MesoWest response") + except IndexError as exc: + LOG.error("Unexpected JSON in MesoWest response: '%s'", exc) + try: + LOG.error("Detailed MesoWest response: '%s'", + json['SUMMARY']['RESPONSE_MESSAGE']) + except KeyError: + pass + sys.exit(1) + except ValueError as exc: + LOG.error("Bad JSON in MesoWest response: '%s'", exc) sys.exit(1) pos = len(observations['date_time']) - 1 -- 2.30.2