I'm writing a decorator to validate some functions. I try to use built-ins as much as possible to do the heavy lifting, but I've been getting stuck on picking which exceptions I should catch when using them.
For example:
def Validated(fun):
def ValidatedFun(*args, **kwargs):
try:
_ = dict(kwargs.get('untrusted_data', ()))
except ? as e:
raise BetterError('Additional relevant info') from e
return fun(*args, **kwargs)
return ValidatedFun
I'd like to know:
- What are the most-derived exceptions that
dict(and other built-ins) explicitly raise? - Where can I find documentation that lists them? (they aren't on https://docs.python.org/)