How do you find what exceptions a class can throw?

2QdxY4RzWzUUiLuE at potatochowder.com 2QdxY4RzWzUUiLuE at potatochowder.com
Sun Dec 20 22:24:00 EST 2020


On 2020-12-20 at 21:46:48 -0500,
Avi Gross via Python-list <python-list at python.org> wrote:

[...]

> I would say it is a more laudable goal for each function to publish
> what interrupts they do NOT handle that might come through and perhaps
> why ...

I'm not disagreeing.  Documenting important decisions and the reasons
behind them is amongst the best of Best Practices.

That said, either way, it's the same thing.  If A calls B, and B calls
C, and B claims *not* to handle exceptions X and Y, then A has to track
down everything else that might come from C, and we're right back to
square one (or square zero, but I digress).

> So, I do sympathize with a wish to be able to decide what errors might
> arise and be able to decide if having your code deal with it makes
> sense. I just suggest whatever you do in the general case may not be
> optimal. It may do too much and yet allow problems to seep through.

Excellent point, and well said.

So how do we eliminate the general case?  ;-)


More information about the Python-list mailing list