From b2a82197160c9b899e60980d40e650e659799df7 Mon Sep 17 00:00:00 2001 From: Dan Blanchard Date: Tue, 1 Aug 2017 16:02:10 -0400 Subject: [PATCH] Make util.get_ui_jsons give better error messages --- streamparse/util.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/streamparse/util.py b/streamparse/util.py index 399db05c..5adaaed7 100644 --- a/streamparse/util.py +++ b/streamparse/util.py @@ -344,10 +344,15 @@ def get_ui_jsons(env_name, api_paths): with ssh_tunnel(env_config, local_port=local_port, remote_port=remote_ui_port) as (host, local_port): for api_path in api_paths: - r = requests.get('http://{}:{}{}'.format(host, - local_port, - api_path)) + url = 'http://{}:{}{}'.format(host, local_port, api_path) + r = requests.get(url) data[api_path] = r.json() + error = data[api_path].get('error') + if error: + error_msg = data[api_path].get('errorMessage') + raise RuntimeError('Received bad response from {}: ' + '{}\n{}' + .format(url, error, error_msg)) return data except Exception as e: if "already in use" in str(e):