Hello, On Thu, 9 Apr 2020 17:40:26 -0300 André Roberge <andre.robe...@gmail.com> wrote:
> On Thu, Apr 9, 2020 at 5:31 PM Soni L. <fakedme...@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... [] -- Best regards, Paul mailto:pmis...@gmail.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/MGDU2BFPPN4SO3ZTVCFUJNVTAA5U5C4J/ Code of Conduct: http://python.org/psf/codeofconduct/