Conditionally use unit name in exception