1. We can raise a ValueError (or something else more specific) instead of a generic Exception.
2. In general, if there are "just give up if this precondition is not met", please shift it to the beginning of the method.