Throw exception if the entity type is invalid.