Improve logging and catch an unexpected exception