[Pkg-javascript-commits] [uglifyjs] 168/190: Normalize error messages
Antonio Terceiro
terceiro at moszumanska.debian.org
Sun Aug 7 23:17:23 UTC 2016
This is an automated email from the git hooks/post-receive script.
terceiro pushed a commit to annotated tag upstream/2.7.0
in repository uglifyjs.
commit 6c99816855b650c6804a67f4891c339a3e8970f4
Author: Anthony Van de Gejuchte <anthonyvdgent at gmail.com>
Date: Sat Jun 18 17:28:22 2016 +0200
Normalize error messages
---
lib/parse.js | 32 ++++++++++++++++----------------
test/mocha/directives.js | 4 ++--
test/mocha/getter-setter.js | 2 +-
test/mocha/with.js | 2 +-
4 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/lib/parse.js b/lib/parse.js
index 9b5a142..a573234 100644
--- a/lib/parse.js
+++ b/lib/parse.js
@@ -762,14 +762,14 @@ function parse($TEXT, options) {
function unexpected(token) {
if (token == null)
token = S.token;
- token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
+ token_error(token, "SyntaxError: Unexpected token: " + token.type + " (" + token.value + ")");
};
function expect_token(type, val) {
if (is(type, val)) {
return next();
}
- token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
+ token_error(S.token, "SyntaxError: Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
};
function expect(punc) { return expect_token("punc", punc); };
@@ -898,7 +898,7 @@ function parse($TEXT, options) {
case "return":
if (S.in_function == 0 && !options.bare_returns)
- croak("'return' outside of function");
+ croak("SyntaxError: 'return' outside of function");
return new AST_Return({
value: ( is("punc", ";")
? (next(), null)
@@ -915,7 +915,7 @@ function parse($TEXT, options) {
case "throw":
if (S.token.nlb)
- croak("Illegal newline after 'throw'");
+ croak("SyntaxError: Illegal newline after 'throw'");
return new AST_Throw({
value: (tmp = expression(true), semicolon(), tmp)
});
@@ -931,7 +931,7 @@ function parse($TEXT, options) {
case "with":
if (S.input.has_directive("use strict")) {
- croak("Strict mode may not include a with statement");
+ croak("SyntaxError: Strict mode may not include a with statement");
}
return new AST_With({
expression : parenthesised(),
@@ -951,7 +951,7 @@ function parse($TEXT, options) {
// syntactically incorrect if it contains a
// LabelledStatement that is enclosed by a
// LabelledStatement with the same Identifier as label.
- croak("Label " + label.name + " defined twice");
+ croak("SyntaxError: Label " + label.name + " defined twice");
}
expect(":");
S.labels.push(label);
@@ -964,7 +964,7 @@ function parse($TEXT, options) {
label.references.forEach(function(ref){
if (ref instanceof AST_Continue) {
ref = ref.label.start;
- croak("Continue label `" + label.name + "` refers to non-IterationStatement.",
+ croak("SyntaxError: Continue label `" + label.name + "` refers to non-IterationStatement.",
ref.line, ref.col, ref.pos);
}
});
@@ -984,11 +984,11 @@ function parse($TEXT, options) {
if (label != null) {
ldef = find_if(function(l){ return l.name == label.name }, S.labels);
if (!ldef)
- croak("Undefined label " + label.name);
+ croak("SyntaxError: Undefined label " + label.name);
label.thedef = ldef;
}
else if (S.in_loop == 0)
- croak(type.TYPE + " not inside a loop or switch");
+ croak("SyntaxError: " + type.TYPE + " not inside a loop or switch");
semicolon();
var stat = new type({ label: label });
if (ldef) ldef.references.push(stat);
@@ -1004,7 +1004,7 @@ function parse($TEXT, options) {
: expression(true, true);
if (is("operator", "in")) {
if (init instanceof AST_Var && init.definitions.length > 1)
- croak("Only one variable declaration allowed in for..in loop");
+ croak("SyntaxError: Only one variable declaration allowed in for..in loop");
next();
return for_in(init);
}
@@ -1154,7 +1154,7 @@ function parse($TEXT, options) {
});
}
if (!bcatch && !bfinally)
- croak("Missing catch/finally blocks");
+ croak("SyntaxError: Missing catch/finally blocks");
return new AST_Try({
body : body,
bcatch : bcatch,
@@ -1248,8 +1248,8 @@ function parse($TEXT, options) {
break;
case "operator":
if (!is_identifier_string(tok.value)) {
- throw new JS_Parse_Error("Invalid getter/setter name: " + tok.value,
- tok.file, tok.line, tok.col, tok.pos);
+ croak("SyntaxError: Invalid getter/setter name: " + tok.value,
+ tok.line, tok.col, tok.pos);
}
ret = _make_symbol(AST_SymbolRef);
break;
@@ -1399,7 +1399,7 @@ function parse($TEXT, options) {
function as_symbol(type, noerror) {
if (!is("name")) {
- if (!noerror) croak("Name expected");
+ if (!noerror) croak("SyntaxError: Name expected");
return null;
}
var sym = _make_symbol(type);
@@ -1463,7 +1463,7 @@ function parse($TEXT, options) {
function make_unary(ctor, op, expr) {
if ((op == "++" || op == "--") && !is_assignable(expr))
- croak("Invalid use of " + op + " operator");
+ croak("SyntaxError: Invalid use of " + op + " operator");
return new ctor({ operator: op, expression: expr });
};
@@ -1527,7 +1527,7 @@ function parse($TEXT, options) {
end : prev()
});
}
- croak("Invalid assignment");
+ croak("SyntaxError: Invalid assignment");
}
return left;
};
diff --git a/test/mocha/directives.js b/test/mocha/directives.js
index 604b032..45f454b 100644
--- a/test/mocha/directives.js
+++ b/test/mocha/directives.js
@@ -168,7 +168,7 @@ describe("Directives", function() {
throw new Error("Expected parser to fail");
} catch (e) {
assert.strictEqual(e instanceof uglify.JS_Parse_Error, true);
- assert.strictEqual(e.message, "Unexpected token: punc (])");
+ assert.strictEqual(e.message, "SyntaxError: Unexpected token: punc (])");
}
test_directive(tokenizer, tests[i]);
@@ -367,4 +367,4 @@ describe("Directives", function() {
);
}
});
-});
\ No newline at end of file
+});
diff --git a/test/mocha/getter-setter.js b/test/mocha/getter-setter.js
index 641a202..a292fa0 100644
--- a/test/mocha/getter-setter.js
+++ b/test/mocha/getter-setter.js
@@ -71,7 +71,7 @@ describe("Getters and setters", function() {
var fail = function(data) {
return function (e) {
return e instanceof UglifyJS.JS_Parse_Error &&
- e.message === "Invalid getter/setter name: " + data.operator;
+ e.message === "SyntaxError: Invalid getter/setter name: " + data.operator;
};
};
diff --git a/test/mocha/with.js b/test/mocha/with.js
index d284f1c..2e758d1 100644
--- a/test/mocha/with.js
+++ b/test/mocha/with.js
@@ -9,7 +9,7 @@ describe("With", function() {
}
var error = function(e) {
return e instanceof uglify.JS_Parse_Error &&
- e.message === "Strict mode may not include a with statement";
+ e.message === "SyntaxError: Strict mode may not include a with statement";
}
assert.throws(test, error);
});
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/uglifyjs.git
More information about the Pkg-javascript-commits
mailing list