Bug: fetch.py swallows ALL exceptions silently — impossible to debug OSM fetch failures
Describe the bug
fetch.py has two bare except Exception as e: blocks that catch and discard every error. When Overpass returns a 429, a timeout, a malformed JSON, or a partial payload, the error is completely swallowed. The user sees Fetching geodataframes took 120s followed by a downstream KeyError with no indication that the actual problem was an Overpass rate-limit.
To reproduce
import prettymaps
prettymaps.plot("Zurich, Switzerland", radius=1800)
# → Fetching geodataframes took 128.19 seconds
# → KeyError: 'highway' ← no indication that Overpass returned empty/partial data
Expected behavior
Errors during OSM data fetching should be logged or surfaced so the user can understand why a render failed and take action (retry, use a different Overpass endpoint, reduce radius, etc.).
Root cause
Line 609 — unified_osm_request main fetch:
try:
all_features = ox.features.features_from_polygon(bbox, tags=combined_tags)
except Exception as e:
all_features = GeoDataFrame(geometry=[]) # silently empty, no log
Line 692 — per-layer split:
except Exception as e:
# print(f"Error fetching {layer}: {e}") ← commented out!
gdfs[layer] = GeoDataFrame(geometry=[])
Suggested fix
- Uncomment the print/log line, or use the
logging module:
except Exception as e:
logging.warning(f"Error fetching layer '{layer}': {e}")
- Distinguish recoverable errors (empty result) from fatal ones (auth, network):
except (ConnectionError, TimeoutError) as e:
raise RuntimeError(f"Overpass API unreachable: {e}") from e
except Exception as e:
logging.warning(f"Layer '{layer}' fetch failed: {e}")
- Surface Overpass 429 responses with a retry hint and
User-Agent header guidance.
Environment
- prettymaps v1.4.2
- Python 3.10.18 (Homebrew)
- osmnx 1.2.2
- macOS 15, ARM64
Bug:
fetch.pyswallows ALL exceptions silently — impossible to debug OSM fetch failuresDescribe the bug
fetch.pyhas two bareexcept Exception as e:blocks that catch and discard every error. When Overpass returns a 429, a timeout, a malformed JSON, or a partial payload, the error is completely swallowed. The user seesFetching geodataframes took 120sfollowed by a downstreamKeyErrorwith no indication that the actual problem was an Overpass rate-limit.To reproduce
Expected behavior
Errors during OSM data fetching should be logged or surfaced so the user can understand why a render failed and take action (retry, use a different Overpass endpoint, reduce radius, etc.).
Root cause
Line 609 —
unified_osm_requestmain fetch:Line 692 — per-layer split:
Suggested fix
loggingmodule:User-Agentheader guidance.Environment