Skip to content

Commit

Permalink
fix(scout): improve error handling (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
tjzegmott authored Jun 4, 2024
1 parent 0a75b28 commit 1937e9b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions dtcli/scout.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@click.option("-v", "--verbose", count=True, help="Verbosity: v=INFO, vv=DEBUG.")
@click.option("-q", "--quiet", is_flag=True, help="Set log level to ERROR.")
@click.pass_context
def scout(
def scout( # noqa: C901
ctx: click.Context,
dataset: str,
scopes: List[str],
Expand Down Expand Up @@ -86,8 +86,20 @@ def scout(
url = server + endpoint
logger.debug(f"URL: {url}")
response = requests.get(url)
data = response.json()
logger.debug(f"Data: {data}")
try:
data = response.json()
logger.debug(f"Data: {data}")
except requests.JSONDecodeError:
if "Response Timeout" in response.text:
error_console.print("Error: Datatrail server timed out.")
return None
else:
error_console.print(f"Error: {response.text}")
return None

if "error" in data.keys():
error_console.print(data["error"])
return None

for scope in data.keys():
basepath = data.get(scope).get("basepath")
Expand Down

0 comments on commit 1937e9b

Please sign in to comment.