`RuntimeError` is an exception to represent errors in the runtime itself.  I suggest something more like `ValueError` here.  On the other hand, this code will all be deleted very soon (#2) so maybe it's irrelevant.