From 1e0675f93ff76195b2534cefd8f277321eff8c40 Mon Sep 17 00:00:00 2001 From: Noah McGregor Harper <74685766+nharper285@users.noreply.github.com> Date: Thu, 2 Mar 2023 17:49:12 +0000 Subject: [PATCH] Resolving Variable Reference Error --- src/cli/onefuzz/backend.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cli/onefuzz/backend.py b/src/cli/onefuzz/backend.py index ec3bc74521..4811d9188a 100644 --- a/src/cli/onefuzz/backend.py +++ b/src/cli/onefuzz/backend.py @@ -415,17 +415,16 @@ def request( if response.status_code // 100 != 2: try: json = response.json() + # attempt to read as https://www.rfc-editor.org/rfc/rfc7807 + if isinstance(json, Dict): + title = json.get("title") + details = json.get("detail") + raise Exception( + f"request did not succeed ({response.status_code}: {title}): {details}" + ) except requests.exceptions.JSONDecodeError: pass - # attempt to read as https://www.rfc-editor.org/rfc/rfc7807 - if isinstance(json, Dict): - title = json.get("title") - details = json.get("detail") - raise Exception( - f"request did not succeed ({response.status_code}: {title}): {details}" - ) - error_text = str( response.content, encoding="utf-8", errors="backslashreplace" )