qapi: Lift error reporting from QAPISchema.__init__() to callers

Backports commit 181feaf3555136dd7883e2434c4498ca1939bf1a from qemu
This commit is contained in:
Markus Armbruster 2018-03-09 08:55:43 -05:00 committed by Lioncash
parent b859a59f49
commit aaa4a812ed
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 15 additions and 16 deletions

View file

@ -8,7 +8,7 @@ from __future__ import print_function
import argparse import argparse
import re import re
import sys import sys
from qapi.common import QAPISchema from qapi.common import QAPIError, QAPISchema
from qapi.types import gen_types from qapi.types import gen_types
from qapi.visit import gen_visit from qapi.visit import gen_visit
# Unicorn: commented out # Unicorn: commented out
@ -40,7 +40,11 @@ def main(argv):
file=sys.stderr) file=sys.stderr)
sys.exit(1) sys.exit(1)
try:
schema = QAPISchema(args.schema) schema = QAPISchema(args.schema)
except QAPIError as err:
print(err, file=sys.stderr)
exit(1)
gen_types(schema, args.output_dir, args.prefix, args.builtins) gen_types(schema, args.output_dir, args.prefix, args.builtins)
gen_visit(schema, args.output_dir, args.prefix, args.builtins) gen_visit(schema, args.output_dir, args.prefix, args.builtins)

View file

@ -16,7 +16,6 @@ import errno
import os import os
import re import re
import string import string
import sys
try: try:
from collections import OrderedDict from collections import OrderedDict
except: except:
@ -1468,7 +1467,6 @@ class QAPISchemaEvent(QAPISchemaEntity):
class QAPISchema(object): class QAPISchema(object):
def __init__(self, fname): def __init__(self, fname):
try:
parser = QAPISchemaParser(open(fname, 'r')) parser = QAPISchemaParser(open(fname, 'r'))
exprs = check_exprs(parser.exprs) exprs = check_exprs(parser.exprs)
self.docs = parser.docs self.docs = parser.docs
@ -1478,9 +1476,6 @@ class QAPISchema(object):
self._predefining = False self._predefining = False
self._def_exprs(exprs) self._def_exprs(exprs)
self.check() self.check()
except QAPIError as err:
print(err, file=sys.stderr)
exit(1)
def _def_entity(self, ent): def _def_entity(self, ent):
# Only the predefined types are allowed to not have info # Only the predefined types are allowed to not have info