Expose ValidationError.loc

This commit is contained in:
Rene Saarsoo 2020-12-25 19:59:21 +02:00
parent 7b30277143
commit f2b293ba21
1 changed files with 4 additions and 2 deletions

View File

@ -1,7 +1,9 @@
import { SourceLocation } from "./tokenizer"; import { SourceLocation } from "./tokenizer";
export class ValidationError extends Error { export class ValidationError extends Error {
constructor(msg: string, { row, col }: SourceLocation) { public loc: SourceLocation;
super(`${msg} at line ${row + 1} char ${col + 1}`); constructor(msg: string, loc: SourceLocation) {
super(`${msg} at line ${loc.row + 1} char ${loc.col + 1}`);
this.loc = loc;
} }
} }