From e80235e111aaca4e8f7e47af76e633df1941c2ec Mon Sep 17 00:00:00 2001 From: Efthymis Sarmpanis Date: Tue, 12 Dec 2017 23:54:21 +0100 Subject: [PATCH] Properly override toString in CompileError --- src/utils/CompileError.ts | 2 +- test/parser/index.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utils/CompileError.ts b/src/utils/CompileError.ts index 1af9b39c2f2f..16dabc3c13f0 100644 --- a/src/utils/CompileError.ts +++ b/src/utils/CompileError.ts @@ -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}`; } diff --git a/test/parser/index.js b/test/parser/index.js index 33e36e98cdcf..1ce8165009a4 100644 --- a/test/parser/index.js +++ b/test/parser/index.js @@ -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;