We catch an exception then only return the error message in the status variable. This is bad since it silences programming errors like OutOfRangeErrors that should be propagated. Note the fix consists of two components:
Using logging.error to add additional context information
Re-raise (not raise another exception) via raise with no arguments. This keeps the stack trace intact for debugging/logs.
2. catching exceptions and raising a wrapped exception
There are two unfortunate use-patterns of exception handlers in the codebase atm:
1. silencing exceptions with status messages
Example and fix.
We catch an exception then only return the error message in the
status
variable. This is bad since it silences programming errors likeOutOfRangeError
s that should be propagated. Note the fix consists of two components:logging.error
to add additional context informationraise
with no arguments. This keeps the stack trace intact for debugging/logs.2. catching exceptions and raising a wrapped exception
Example and fix.
Similar to 1. above, we should be using
logging.error
andraise
with no arguments to add context and re-raise the exception.