From f549ea3ae0e682f13f13073b5500e92179e89cb7 Mon Sep 17 00:00:00 2001 From: Bo Xu Date: Mon, 24 Aug 2020 14:21:33 -0700 Subject: [PATCH] Catch mixer error and re-throw in get_stat_value() --- datacommons/stat_vars.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/datacommons/stat_vars.py b/datacommons/stat_vars.py index ec07569e..d0a42991 100644 --- a/datacommons/stat_vars.py +++ b/datacommons/stat_vars.py @@ -76,10 +76,10 @@ def get_stat_value(place, if scaling_factor: url += '&scaling_factor={}'.format(scaling_factor) - res_json = utils._send_request(url, post=False, use_payload=False) - - if 'value' not in res_json: - raise ValueError('No data in response.') + try: + res_json = utils._send_request(url, post=False, use_payload=False) + except ValueError: + raise ValueError('No data in response.') return res_json['value']