Python Tip #289 (of 365): Add context to exceptions with add_note. def load_conf...
Trey Hunner ๐ @treyhunner@mastodon.social
Python Tip #289 (of 365):
Add context to exceptions with add_note.
def load_config(path):
try:
return json.loads(Path(path).read_text())
except json.JSONDecodeError as error:
error.add_note(f"While parsing {path}")
raise
๐งต (1/4)