From 8c8eaa1916da68f92858091d09795396c8664fa4 Mon Sep 17 00:00:00 2001 From: Wu Tingfeng Date: Mon, 19 Feb 2024 11:40:37 +0800 Subject: [PATCH] Always raise Exception for status_code != 200 --- train_arrival.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/train_arrival.py b/train_arrival.py index 3c628dd..ec7a736 100644 --- a/train_arrival.py +++ b/train_arrival.py @@ -66,8 +66,7 @@ def _get(url, params=None): # type: (str, dict[str, str] | None) -> str data = f.read().decode("utf-8") _ = json.loads(data) # Validate JSON string. return data - logger.error(status_code) - return "{}" + raise Exception(status_code) except Exception as e: logger.error(e) return "{}"