serhii.net

In the middle of the desert you can say anything you want

07 Dec 2023

You can add notes to exceptions

8. Errors and Exceptions — Python 3.12.0 documentation:

try:
...     raise TypeError('bad type')
... except Exception as e:
...     e.add_note('Add some information')
...     e.add_note('Add some more information')
...     raise

A function deep down can raise the exception, then a function higher up can catch it and add more details (uri returns 404 -> when downloading image $image we got a 404).

This solves so many conceptual problems I’ve been having!

Nel mezzo del deserto posso dire tutto quello che voglio.