Adding additional logging and debug information when an exception is thrown