tools/spec: don't raise strings as exceptions

This commit is contained in:
Danny Robson 2019-01-05 12:29:35 +11:00
parent babd86aa2b
commit e592afd8e0

View File

@ -401,7 +401,7 @@ class Constant(Type):
elif 'bitpos' in node.attrib:
self.value = "1 << %s" % node.attrib['bitpos']
else:
raise "Unknown constant value type"
raise RuntimeError("Unknown constant value type")
def declare(self):
return "constexpr auto %(name)s = %(value)s;" % {
@ -497,7 +497,7 @@ class Require(object):
elif node.tag in ['comment']:
pass
else:
raise "Unknown requires node"
raise RuntimeError("Unknown requires node")
def apply(self, reg: Registry, extnumber=None):
required = []
@ -528,7 +528,7 @@ class Require(object):
elif value.tag == 'command':
required.append(name)
else:
raise "Unknown type"
raise RuntimeError("Unknown type")
return required
@ -545,7 +545,7 @@ class Feature(Type):
if 'require' == node.tag:
self.requires.append(Require(node))
else:
raise "Unhandled feature node"
raise RuntimeError("Unhandled feature node")
def define(self, reg: Registry):
return "#define %s" % self.name
@ -579,7 +579,7 @@ class Extension(Type):
if node.tag == 'require':
self.requires.append(Require(node))
else:
raise "Unknown extension node"
raise RuntimeError("Unknown extension node")
def apply(self, reg: Registry, platform: Set[str]):
if self.name in reg.applied:
@ -653,7 +653,7 @@ def parse_types(reg: Registry, root):
if concrete:
reg.types[name] = concrete(t)
else:
raise 'unhandled type'
raise RuntimeError('unhandled type')
if 'requires' in t.attrib:
reg.types[name].depends.append(t.attrib['requires'])