raise a better exception if the target is invalid