Skip to content

Commit

Permalink
Properly override toString in CompileError
Browse files Browse the repository at this point in the history
  • Loading branch information
esarbanis committed Dec 12, 2017
1 parent 0da8191 commit e80235e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/CompileError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class CompileError extends Error {
this.frame = getCodeFrame(template, line, column);
}

toString() {
public toString = () => {
return `${this.message} (${this.loc.line}:${this.loc.column})\n${this
.frame}`;
}
Expand Down
1 change: 1 addition & 0 deletions test/parser/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('parse', () => {
assert.equal(err.message, expected.message);
assert.deepEqual(err.loc, expected.loc);
assert.equal(err.pos, expected.pos);
assert.equal(err.toString().split('\n')[0], `${expected.message} (${expected.loc.line}:${expected.loc.column})`);
} catch (err2) {
const e = err2.code === 'MODULE_NOT_FOUND' ? err : err2;
throw e;
Expand Down

0 comments on commit e80235e

Please sign in to comment.