diff options
author | Felype Santiago Ferreira <felype@vaadin.com> | 2013-12-04 16:06:43 +0200 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-12-10 14:13:52 +0000 |
commit | b5a080cced33ad088ccd269da64ae495000baaa9 (patch) | |
tree | 898aab4667b4a61031ba4ed03d0175f34298be5d /theme-compiler/src | |
parent | 9026cef9719e8607c289bb91515bb23b5b0b9fe5 (diff) | |
download | vaadin-framework-b5a080cced33ad088ccd269da64ae495000baaa9.tar.gz vaadin-framework-b5a080cced33ad088ccd269da64ae495000baaa9.zip |
Provides error location for ArithmeticException. (#11877)
Change-Id: Ieb63ad556c3dc01196f0b9898aed9670923c9138
Diffstat (limited to 'theme-compiler/src')
2 files changed, 22 insertions, 5 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluator.java b/theme-compiler/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluator.java index 7dbd8ae1a0..552b464941 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluator.java +++ b/theme-compiler/src/com/vaadin/sass/internal/expression/ArithmeticExpressionEvaluator.java @@ -99,7 +99,8 @@ public class ArithmeticExpressionEvaluator { continue inputTermLoop; } } - throw new ArithmeticException(); + throw new ArithmeticException("Illegal arithmetic expression", + term); } if (current.getLexicalUnitType() == SCSSLexicalUnit.SCSS_OPERATOR_LEFT_PAREN) { operators.push(Parentheses.LEFT); @@ -115,7 +116,7 @@ public class ArithmeticExpressionEvaluator { while (!operators.isEmpty()) { Object operator = operators.pop(); if (operator == Parentheses.LEFT) { - throw new ArithmeticException("Unexpected \"(\" found"); + throw new ArithmeticException("Unexpected \"(\" found", term); } createNewOperand((BinaryOperator) operator, operands); } @@ -123,7 +124,7 @@ public class ArithmeticExpressionEvaluator { if (!operands.isEmpty()) { LexicalUnitImpl operand = (LexicalUnitImpl) operands.peek(); throw new ArithmeticException("Unexpected operand " - + operand.toString() + " found"); + + operand.toString() + " found", term); } return expression; } diff --git a/theme-compiler/src/com/vaadin/sass/internal/expression/exception/ArithmeticException.java b/theme-compiler/src/com/vaadin/sass/internal/expression/exception/ArithmeticException.java index 13b6f0e936..f9ab90fc32 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/expression/exception/ArithmeticException.java +++ b/theme-compiler/src/com/vaadin/sass/internal/expression/exception/ArithmeticException.java @@ -15,12 +15,28 @@ */ package com.vaadin.sass.internal.expression.exception; +import com.vaadin.sass.internal.parser.LexicalUnitImpl; + public class ArithmeticException extends RuntimeException { public ArithmeticException(String errorMsg) { super(errorMsg); } - public ArithmeticException() { - super("Illegal arithmetic expression"); + public ArithmeticException(String error, LexicalUnitImpl term) { + super(buildMessage(error, term)); + } + + private static String buildMessage(String message, LexicalUnitImpl term) { + StringBuilder builder = new StringBuilder(message); + + builder.append(": \""); + builder.append(term.toString()); + builder.append("\" ["); + builder.append(term.getLineNumber()); + builder.append(","); + builder.append(term.getColumnNumber()); + builder.append("]"); + + return builder.toString(); } } |