There are a lot of places in the code where exceptions instead of assertions should be used. Assertions should only be used to check for conditions that are logically impossible to happen and should not be relied upon to always be called (see docs). In cases such as bad inputs to user facing functions, appropriate exceptions such as ArgumentError should be thrown.