Skip to content

Commit 3fc7ea6

Browse files
committed
Merge pull request #189 from cscott/gh-169
Make SyntaxError properly inherit from Error.
2 parents 2387d36 + 9cbed55 commit 3fc7ea6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/util/SyntaxError.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* @param {int} col The column at which the error occurred.
99
*/
1010
function SyntaxError(message, line, col){
11+
Error.call(this);
12+
this.name = this.constructor.name;
1113

1214
/**
1315
* The column at which the error occurred.
@@ -33,4 +35,5 @@ function SyntaxError(message, line, col){
3335
}
3436

3537
//inherit from Error
36-
SyntaxError.prototype = new Error();
38+
SyntaxError.prototype = Object.create(Error.prototype); // jshint ignore:line
39+
SyntaxError.prototype.constructor = SyntaxError; // jshint ignore:line

0 commit comments

Comments
 (0)