check-snapshots: make exception for snapshot cache more targeted
The code in `check-snapshots` will print "No snapshots cache found at ..." regardless of the error that happens when trying to open the file. This can be misleading if e.g. the issue is permissions to open the file or the file is corrupted. So make the exception more targeted and only catch FileNotFound error and let python how the full error for the other cases. Obviously this can be done in many ways so I'm happy to tweak and e.g. keep catching all exception but print the value etc.
This commit is contained in:
parent
2c86e90d05
commit
34cda2e1e3
1 changed files with 2 additions and 2 deletions
|
|
@ -23,7 +23,7 @@ def fetch_snapshots_api(url, timeout=SNAPSHOTS_TIMEOUT):
|
|||
start = time.time()
|
||||
try:
|
||||
r = requests.get(url, timeout=timeout)
|
||||
except BaseException: # pylint: disable=broad-exception-caught
|
||||
except BaseException as e: # pylint: disable=broad-exception-caught
|
||||
return None
|
||||
elapsed = time.time() - start
|
||||
if r.status_code != 200:
|
||||
|
|
@ -168,7 +168,7 @@ def main():
|
|||
try:
|
||||
with open(args.cache, encoding="utf8") as f:
|
||||
snapshots = json.load(f)
|
||||
except BaseException: # pylint: disable=broad-exception-caught
|
||||
except FileNotFoundError:
|
||||
print(f"No snapshots cache found at {args.cache}")
|
||||
sys.exit(1)
|
||||
else:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue