raise error if preconditions fail