Hello,
On Thu, 9 Apr 2020 17:40:26 -0300 André Roberge andre.roberge@gmail.com wrote:
On Thu, Apr 9, 2020 at 5:31 PM Soni L. fakedme+py@gmail.com 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.
... And if you have a problem with a 3rd-party lib, drop them a bug report. And if they don't listen (everybody is smart nowadays and knows better how it should be), just fork that lib, and show everyone how to do it right...
[]