logging the caught exceptions