Refactor exception repetition