Skip to content

Commit 1407ece

Browse files
committed
Improve template parser Exceptions message
1 parent d1d3ad1 commit 1407ece

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

src/main/java/com/axellience/vuegwt/template/parser/TemplateParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@ private void processNameExpression(Expression expression, NameExpr nameExpr,
506506
VariableInfo variableInfo = context.findVariable(name);
507507
if (variableInfo == null)
508508
{
509-
throw new TemplateExpressionException("Couldn't find variable \""
509+
throw new TemplateExpressionException("Couldn't find variable/method \""
510510
+ name
511-
+ "\" in the Component.\nMake sure you didn't forget the @JsProperty annotation or try rerunning your Annotation processor.",
511+
+ "\" in the Component.\nMake sure you didn't forget the @JsProperty/@JsMethod annotation or try rerunning your Annotation processor.",
512512
expression.toString(),
513513
context);
514514
}

src/main/java/com/axellience/vuegwt/template/parser/context/TemplateParserContext.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import java.util.HashMap;
1818
import java.util.Map;
1919

20+
import static com.axellience.vuegwt.jsr69.GenerationNameUtil.COMPONENT_JS_TYPE_SUFFIX;
21+
2022
/**
2123
* Context of the parser.
2224
* This holds information about imports and variable that exist in the Component.
@@ -246,12 +248,14 @@ public void setCurrentNode(Node currentNode)
246248
}
247249

248250
/**
249-
* Simple getter for the currently processed VueComponentClass.
251+
* Simple getter for the currently processed {@link VueComponent} Template name.
250252
* Used for debugging.
251-
* @return The currently process VueComponent class
253+
* @return The currently process {@link VueComponent} Template name
252254
*/
253-
public JClassType getComponentJsTypeClass()
255+
public String getTemplateName()
254256
{
255-
return componentJsTypeClass;
257+
String componentJsTypeName = componentJsTypeClass.getName();
258+
return componentJsTypeName.substring(0,
259+
componentJsTypeName.length() - COMPONENT_JS_TYPE_SUFFIX.length()) + ".html";
256260
}
257261
}

src/main/java/com/axellience/vuegwt/template/parser/exceptions/TemplateParserException.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@ public TemplateParserException(String message, TemplateParserContext context)
1616
public TemplateParserException(String message, TemplateParserContext context, Throwable cause)
1717
{
1818
super("\n\n======================= Error in: \""
19-
+ context
20-
.getComponentJsTypeClass()
21-
.getName()
22-
+ ".html\" =======================\n\n"
19+
+ context.getTemplateName()
20+
+ "\" =======================\n\n"
2321
+ message
2422
+ "\n\nWhile processing Node: "
2523
+ context.getCurrentNode().toString()

0 commit comments

Comments
 (0)