On Thu, Apr 9, 2020 at 5:31 PM Soni L. <[email protected]> wrote:
> Sometimes, you have an API:
>
> SNIP
> Raises:
> PropertyError: If the property is not supported by this config
> source.
> LookupError: If the property is supported, but isn't
> available.
> ValueError: If the property doesn't have exactly one value.
> """
> raise PropertyError
>
> and you don't want your API to mask bugs. How would it mask bugs? For
> example, if API consumers do an:
>
> try:
> x = foo.get_property_value(prop)
> except ValueError:
> # handle it
>
> SNIP
If you don't want standard Python exceptions, such as ValueError to be
confused with exceptions from your own app, just create your own custom
exceptions such as
class MyAppValueError(Exception):
pass
and raise these custom exceptions when necessary.
No need to change Python or use convoluted logic.
André Roberge
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/J76S2NBEVKX2MHZULELM22IHT5H7KLP3/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/BTSK3CPKYUMZII7VIEFWWVYB76GKB455/
Code of Conduct: http://python.org/psf/codeofconduct/