From 0c5b031f834248819e2d92895f44a18c5a3fcc59 Mon Sep 17 00:00:00 2001 From: Nicholas Reinicke Date: Thu, 30 May 2024 09:37:35 -0600 Subject: [PATCH] more informative download error --- pyproject.toml | 2 +- python/nrel/routee/compass/io/utils.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 9009ddf0..60b1b18c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "maturin" [project] name = "nrel.routee.compass" -version = "0.8.0" +version = "0.8.1" description = "An eco-routing tool build upon RouteE-Powertrain" readme = "README.md" documentation = "nrel.github.io/routee-compass" diff --git a/python/nrel/routee/compass/io/utils.py b/python/nrel/routee/compass/io/utils.py index e7de9de4..6cbab26a 100644 --- a/python/nrel/routee/compass/io/utils.py +++ b/python/nrel/routee/compass/io/utils.py @@ -86,7 +86,13 @@ def _download_tile( with requests.get(url, stream=True) as r: log.info(f"downloading {tile}") - r.raise_for_status() + try: + r.raise_for_status() + except requests.exceptions.HTTPError as e: + raise ValueError( + f"Failed to download USGS tile {tile} from {url}. " + "If this road network is outside of the US, consider re-running with `grade=False`." + ) from e destination.parent.mkdir(exist_ok=True)