From 6738e87abb68b5baa2fd7b040466738594d34df0 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Mon, 20 Mar 2023 10:23:30 +0300 Subject: corrs: Handle JSONDecodeError In the case that the JSON output from the correlations computation is malformed, we capture that into a new exception an re-raise it to help with debugging and fixing issues. --- wqflask/wqflask/views.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py index f2d20eef..c71ae3c3 100644 --- a/wqflask/wqflask/views.py +++ b/wqflask/wqflask/views.py @@ -901,9 +901,13 @@ def corr_compute_page(): return render_template("correlation_page.html", **output) if jobs.completed_erroneously(job): - ## The "parseable" error report is actually in STDOUT - output = json.loads(job.get("stdout", "{}")) - return render_template("correlation_error_page.html", error=output) + try: + ## The "parseable" error report is actually in STDOUT + output = json.loads(job.get("stdout") or "{}") + return render_template( + "correlation_error_page.html", error=output) + except json.decoder.JSONDecodeError as jde: + raise Exception(f"STDOUT: {job.get('stdout')}") from jde return render_template("loading_corrs.html") -- cgit v1.2.3