Refactor step 4: narrow broad except Exception catches
Replaced 28 bare `except Exception` catches across 8 files with specific exception types reflecting the actual failure modes: - JSON file reads → (OSError, json.JSONDecodeError) - datetime parsing → ValueError - base64 decoding → ValueError - YAML parsing → (OSError, yaml.YAMLError); import moved above try - GeoJSON coord extraction → (TypeError, IndexError, AttributeError) - Startup temp-file cleanup → OSError - Single JSON line parsing (SSE batch) → json.JSONDecodeError Kept broad catches only where intentional: - Background thread top-level guards (tasks.py, admin.py) with log.exception - SSE stream generator tops (strava.py, garmin.py, uploads.py) - Per-item batch loops that must not abort the whole operation - Explicitly non-fatal post-upload merge steps with log.warning
This commit is contained in:
@@ -39,7 +39,7 @@ async def _on_startup() -> None:
|
||||
for p in _glob.glob(str(data_dir / "*" / "tmp*.zip")):
|
||||
try:
|
||||
Path(p).unlink()
|
||||
except Exception:
|
||||
except OSError:
|
||||
pass
|
||||
if deps.webroot is not None:
|
||||
threading.Thread(target=tasks._site_rebuild_worker, daemon=True, name="site-rebuild").start()
|
||||
|
||||
Reference in New Issue
Block a user