Refactor exception type logging