Adding a logging message if an exception is raised