core: Throw exceptions rather than asserts.