Best practice for handling exceptions raised at lower levels?

Barry Scott barry at barrys-emacs.org
Tue Feb 2 16:42:40 EST 2021



> On 2 Feb 2021, at 20:24, Dan Stromberg <drsalists at gmail.com> wrote:
> 
> 
> 
> On Tue, Feb 2, 2021 at 12:00 PM Barry Scott <barry at barrys-emacs.org <mailto:barry at barrys-emacs.org>> wrote:
> When I write packages I aim to trap the exceptions from the lower levels
> and convert into a package specific exceptions or document that a low 
> level exception can propagate.
> But how do you know what exceptions could be raised?

By reading the code of the modules I use.

Yes that is tedious and time consuming. I can understand why most users will not want to d this.

> I love Python in a big way, but this is one thing Java has on Python - knowing what exceptions are relevant.
> 
> Python's approach is great as long as an uncaught exception should cause termination of the program - and most of my programs fit into this category.  But not all of them.
> 

Barry



More information about the Python-list mailing list