On 13.10.2020 03:51, jmwar...@gmail.com wrote:
> Of course, again, looking at the requests code shows just how much 
> boilerplate these things take up. The base class RequestException has some 
> code in it but then there are 22 derived exceptions. So many classes defined 
> just to give a name to an exception and none of them have special parameters 
> guaranteed in the exception that might help you better handle what happened.

Exception classes are often built using inheritance to allow for
grouping certain error conditions, e.g. you can catch the
RequestException if you want to catch most exceptions raised
by the requests package.

It's common for more complex packages to come with such a (class)
hierarchy and allows for applications using those packages to narrow
down their error handling without requiring a deep understanding of the
internals of the package.

Regarding passing in more context to an exception object: How you
design this is really up to you. Because exceptions are regular
Python classes you can add methods to them, interpret their
arguments in special ways and even put exception resolving code
directly into the class.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Experts (#1, Oct 13 2020)
>>> Python Projects, Coaching and Support ...    https://www.egenix.com/
>>> Python Product Development ...        https://consulting.egenix.com/
________________________________________________________________________

::: We implement business ideas - efficiently in both time and costs :::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               https://www.egenix.com/company/contact/
                     https://www.malemburg.com/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/QYKFZHP64NDGIVMNK3GW7F6MYYFI2CSV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to