added code to log the exceptions thrown