Replace RuntimeError exception with more properly ValueError exception.