Change assertions to exceptions.