summaryrefslogtreecommitdiff
path: root/qface
diff options
context:
space:
mode:
authorDominik Holland <dominik.holland@qt.io>2021-07-02 14:50:17 +0200
committerDominik Holland <dominik.holland@googlemail.com>2022-01-27 13:50:04 +0100
commit83997b162cb833180d88b907f601360c19477c37 (patch)
treedcb5f79beed57392657889715049a529339b0f91 /qface
parentab47a3df914b4e34bc73f888abb4c59abf8a063e (diff)
downloadqtivi-qface-83997b162cb833180d88b907f601360c19477c37.tar.gz
Improve error reporting in qface files
Only report the errors once using our own ErrorHandler. Also fix a bug which prevented the error message to be shown.
Diffstat (limited to 'qface')
-rw-r--r--qface/generator.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/qface/generator.py b/qface/generator.py
index e260ed4..47cfd82 100644
--- a/qface/generator.py
+++ b/qface/generator.py
@@ -62,7 +62,7 @@ class ReportingErrorListener(ErrorListener.ErrorListener):
self.document = document
def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e):
- msg = '{0}:{1}:{2} {2}'.format(self.document, line, column, msg)
+ msg = '{0}:{1}:{2} {3}'.format(self.document, line, column, msg)
click.secho(msg, fg='red')
raise ValueError(msg)
@@ -301,6 +301,9 @@ class FileSystem(object):
click.secho('{0}: error: file not found'.format(document), fg='red', err=True)
error = True
except ValueError as e:
+ # The error is already printed in the ErrorHandler in this case
+ error = True
+ except Exception as e:
click.secho('Error parsing document {0}'.format(document), fg='red', err=True)
error = True
if error and FileSystem.strict:
@@ -332,6 +335,7 @@ class FileSystem(object):
lexer = TLexer(stream)
stream = CommonTokenStream(lexer)
parser = TParser(stream)
+ parser.removeErrorListeners()
parser.addErrorListener(ReportingErrorListener(document))
tree = parser.documentSymbol()
walker = ParseTreeWalker()