Do not use KeyError, TypeError and IndexError
The built-in exception KeyError
often occurs in case of bugs in the interpreter. Therefore, it may not be used to raise domain-specific exceptions. Specifically, in get_property_type()
it should be replaced by a specific exception, e.g. InvalidKey
and handled in errors.py
. Unexpected KeyError
should remain non-handled.
The same holds for 'TypeError' and 'IndexError'. Bugs in the interpreter cause such exceptions and they are caught by the handler. This should not happen!
Other built-in exceptions being caught by the handler are ValueError
and ArithmeticError
but these are not very frequently raised due to interpreter bugs. Nevertheless, they should not be used for domain-specific purposes.