Added code to log the exception thrown