diff options
Diffstat (limited to 'src/main/javassist/compiler/CompileError.java')
-rw-r--r-- | src/main/javassist/compiler/CompileError.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/main/javassist/compiler/CompileError.java b/src/main/javassist/compiler/CompileError.java index 5b857cf2..3a41779c 100644 --- a/src/main/javassist/compiler/CompileError.java +++ b/src/main/javassist/compiler/CompileError.java @@ -25,12 +25,19 @@ public class CompileError extends Exception { private Lex lex; private String reason; + private int lineNumber = -1; + public CompileError(String s, Lex l) { - reason = s; + this(s, l.getLineNumber()); lex = l; } - public CompileError(String s) { + public CompileError(String s, int lineNumber) { + this.lineNumber = lineNumber; + reason = String.format("line %d: %s", lineNumber, s); + } + + private CompileError(String s) { reason = s; lex = null; } @@ -45,6 +52,10 @@ public class CompileError extends Exception { public Lex getLex() { return lex; } + public int getLineNumber() { + return lineNumber; + } + @Override public String getMessage() { return reason; |