corrected logging when there is an exception