Improve error output from failing to parse examples
This commit is contained in:
parent
a36bd1a6d2
commit
9150ba0dce
1 changed files with 18 additions and 8 deletions
|
@ -694,15 +694,25 @@ class MatrixUnits(Units):
|
||||||
for filename in os.listdir(path):
|
for filename in os.listdir(path):
|
||||||
if not filename.startswith("m."):
|
if not filename.startswith("m."):
|
||||||
continue
|
continue
|
||||||
with open(os.path.join(path, filename), "r") as f:
|
|
||||||
event_name = filename.split("#")[0]
|
|
||||||
example = json.loads(f.read())
|
|
||||||
|
|
||||||
examples[filename] = examples.get(filename, [])
|
event_name = filename.split("#")[0]
|
||||||
examples[filename].append(example)
|
filepath = os.path.join(path, filename)
|
||||||
if filename != event_name:
|
logger.info("Reading event example: %s" % filepath)
|
||||||
examples[event_name] = examples.get(event_name, [])
|
try:
|
||||||
examples[event_name].append(example)
|
with open(filepath, "r") as f:
|
||||||
|
example = json.load(f)
|
||||||
|
examples[filename] = examples.get(filename, [])
|
||||||
|
examples[filename].append(example)
|
||||||
|
if filename != event_name:
|
||||||
|
examples[event_name] = examples.get(event_name, [])
|
||||||
|
examples[event_name].append(example)
|
||||||
|
except Exception, e:
|
||||||
|
e2 = Exception("Error reading event example "+filepath+": "+
|
||||||
|
str(e))
|
||||||
|
# throw the new exception with the old stack trace, so that
|
||||||
|
# we don't lose information about where the error occurred.
|
||||||
|
raise e2, None, sys.exc_info()[2]
|
||||||
|
|
||||||
return examples
|
return examples
|
||||||
|
|
||||||
def load_event_schemas(self):
|
def load_event_schemas(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue