My view is that exceptions are for exceptional code, not for simple logical 
errors. As such anything that can be prevented by simple checks in your code 
should not be caught but rather handled with checks(in the case the checks are 
cheaper and not complex). KeyError is different than IndexError for the 
complexity reason mentioned, to check if an index is valid it's a simple `a in 
typeof(arr).low .. typeof(arr).high` whereas a checking if a key is in a table 
is a hash of the type, which can be relatively expensive. Then there are also 
procedures that let you avoid a `KeyError`. Defects inform the programmer they 
have a logic error that can be prevented easily and cheaply, exceptions inform 
the programmer there is something out of their control causing an error.

Reply via email to