pyOpenSci / lessons

A repo containing lessons used in pyOpenSci training.
https://www.pyopensci.org/lessons
BSD 3-Clause "New" or "Revised" License
3 stars 4 forks source link

Refinements on exception handling - notes, chaining, and etc. #72

Closed sneakers-the-rat closed 1 month ago

sneakers-the-rat commented 1 month ago

Reading through this lesson, and i am reminded of this problem i'm dealing with currently where pydantic truncates the traceback (for a different reason, because the exception happens in rust, but the structure of the problem is the same), and wanting to balance setting up our students to avoid footguns in the future while not overwhelming them with complexity.

In general it's good to avoid totally breaking exception chains unless they are for sure base python exceptions from builtins that everyone would be familiar with because you might obscure information from deeper in the chain (and you also don't have to repeat the information in the exception). Instead if you want to add information to an exception you can use add_note .

So while I was adding that change, i noticed a few other things that seemed related and so i changed a lot more text than i intended to here. ignore this and we can handle it after the fall festival if we're too close for this big of a change.

I also added rich to pretty print the dictionary, and also because i love rich and i always use it in docs

lwasser commented 1 month ago

@sneakers-the-rat let's merge this as is.

i noticed a weird intro (that i missed fixing) in the rendered page and i do like what you've added.

NEW ISSUE: I think we need to explain what exception chaining is in this lesson. I can make a graphic for it. i'll open the issue now. and then merge this.