mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 12:50:38 -07:00
refactor: move file to token property
This commit is contained in:
+17
-3
@@ -8,9 +8,10 @@ function TokenizationError(message, token) {
|
||||
|
||||
this.input = token.input;
|
||||
this.line = token.line;
|
||||
this.file = token.file;
|
||||
|
||||
var context = mkContext(token.input, token.line);
|
||||
this.message = message + ', line:' + token.line;
|
||||
this.message = mkMessage(message, token);
|
||||
this.stack = context + '\n' + (this.stack || '');
|
||||
}
|
||||
TokenizationError.prototype = Object.create(Error.prototype);
|
||||
@@ -22,9 +23,10 @@ function ParseError(e, token) {
|
||||
|
||||
this.input = token.input;
|
||||
this.line = token.line;
|
||||
this.file = token.file;
|
||||
|
||||
var context = mkContext(token.input, token.line);
|
||||
this.message = e.message + ', line:' + token.line;
|
||||
this.message = mkMessage(e.message, token);
|
||||
this.stack = context + '\n' + (this.stack || '');
|
||||
}
|
||||
ParseError.prototype = Object.create(Error.prototype);
|
||||
@@ -40,9 +42,10 @@ function RenderError(e, tpl) {
|
||||
|
||||
this.input = tpl.token.input;
|
||||
this.line = tpl.token.line;
|
||||
this.file = tpl.token.file;
|
||||
|
||||
var context = mkContext(tpl.token.input, tpl.token.line);
|
||||
this.message = e.message + ', line:' + tpl.token.line;
|
||||
this.message = mkMessage(e.message, tpl.token);
|
||||
this.stack = context + '\n' + (e.stack || '');
|
||||
}
|
||||
RenderError.prototype = Object.create(Error.prototype);
|
||||
@@ -93,6 +96,17 @@ function align(n, max) {
|
||||
return blank + str;
|
||||
}
|
||||
|
||||
function mkMessage(msg, token){
|
||||
msg = msg || '';
|
||||
if(token.file){
|
||||
msg += ', file:' + token.file;
|
||||
}
|
||||
if(token.line){
|
||||
msg += ', line:' + token.line;
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
TokenizationError,
|
||||
ParseError,
|
||||
|
||||
Reference in New Issue
Block a user