Skip to content

Commit

Permalink
Print backtrace for errors in mako templates
Browse files Browse the repository at this point in the history
Print the exact location of errors in mako templates by printing a full
backtrace instead of a stripped output without the file:line information
  • Loading branch information
PatKamin committed Jan 29, 2024
1 parent 73d85ef commit 19751cd
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions scripts/util.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Copyright (C) 2022 Intel Corporation
Copyright (C) 2022-2024 Intel Corporation
Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions.
See LICENSE.TXT
Expand All @@ -14,7 +14,7 @@
import json
import yaml
from mako.template import Template
from mako.exceptions import RichTraceback
from mako import exceptions
try:
from yaml import CLoader as Loader, CDumper as Dumper
except ImportError:
Expand Down Expand Up @@ -161,13 +161,7 @@ def makoWrite(inpath, outpath, **args):
makoFileList.append(outpath)
return len(rendered.splitlines())
except:
traceback = RichTraceback()
#for (filename, lineno, function, line) in traceback.traceback:
# print("%s(%s) : error in %s" % (filename, lineno, function))
# print(line, "\n")
line = "%s: %s" % (str(traceback.error.__class__.__name__), traceback.error)
makoErrorList.append(line)
print(line)
print(exceptions.text_error_template().render())
raise

def makoFileListWrite(outpath):
Expand Down

0 comments on commit 19751cd

Please sign in to comment.