From 914880e1d7bf4760e997bfe47b81059dc0a53741 Mon Sep 17 00:00:00 2001 From: Moritz Eysholdt Date: Fri, 7 Oct 2016 14:58:28 +0200 Subject: [PATCH] [XtextGenerator] improve error reporting Signed-off-by: Moritz Eysholdt --- .../xtext/xtext/generator/XtextGeneratorLanguage.xtend | 5 +++-- .../xtext/xtext/generator/XtextGeneratorLanguage.java | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGeneratorLanguage.xtend b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGeneratorLanguage.xtend index 09c98c2c7..517459086 100644 --- a/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGeneratorLanguage.xtend +++ b/org.eclipse.xtext.xtext.generator/src/org/eclipse/xtext/xtext/generator/XtextGeneratorLanguage.xtend @@ -202,10 +202,11 @@ class XtextGeneratorLanguage extends CompositeGeneratorFragment2 implements IXte override add(Diagnostic diagnostic) { if (diagnostic.severity == Diagnostic.ERROR) { + val grammarName = "Validation Error in " + grammar.name + ": " if (diagnostic.exception == null) - throw new IllegalStateException(diagnostic.message) + throw new IllegalStateException(grammarName + diagnostic.message) else - throw new IllegalStateException(diagnostic.message, diagnostic.exception) + throw new IllegalStateException(grammarName + diagnostic.message, diagnostic.exception) } } diff --git a/org.eclipse.xtext.xtext.generator/xtend-gen/org/eclipse/xtext/xtext/generator/XtextGeneratorLanguage.java b/org.eclipse.xtext.xtext.generator/xtend-gen/org/eclipse/xtext/xtext/generator/XtextGeneratorLanguage.java index fc60fbccc..737822661 100644 --- a/org.eclipse.xtext.xtext.generator/xtend-gen/org/eclipse/xtext/xtext/generator/XtextGeneratorLanguage.java +++ b/org.eclipse.xtext.xtext.generator/xtend-gen/org/eclipse/xtext/xtext/generator/XtextGeneratorLanguage.java @@ -331,15 +331,20 @@ public class XtextGeneratorLanguage extends CompositeGeneratorFragment2 implemen int _severity = diagnostic.getSeverity(); boolean _equals = (_severity == Diagnostic.ERROR); if (_equals) { + String _name = grammar.getName(); + String _plus = ("Validation Error in " + _name); + final String grammarName = (_plus + ": "); Throwable _exception = diagnostic.getException(); boolean _equals_1 = Objects.equal(_exception, null); if (_equals_1) { String _message = diagnostic.getMessage(); - throw new IllegalStateException(_message); + String _plus_1 = (grammarName + _message); + throw new IllegalStateException(_plus_1); } else { String _message_1 = diagnostic.getMessage(); + String _plus_2 = (grammarName + _message_1); Throwable _exception_1 = diagnostic.getException(); - throw new IllegalStateException(_message_1, _exception_1); + throw new IllegalStateException(_plus_2, _exception_1); } } }