mirror of https://github.com/tycrek/ass
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
760 B
28 lines
760 B
import { TemplateSourceRange } from "ass";
|
|
|
|
export class TemplateError extends Error {
|
|
range?: TemplateSourceRange;
|
|
|
|
constructor(msg: string, range?: TemplateSourceRange) {
|
|
super(msg);
|
|
|
|
this.range = range;
|
|
}
|
|
|
|
public format(): string {
|
|
let format = '';
|
|
|
|
if (this.range) {
|
|
format += this.range.file.code + '\n';
|
|
format += ' '.repeat(this.range.from) + '^' + '~'.repeat(Math.max(this.range.to - this.range.from, 0)) + '\n';
|
|
}
|
|
|
|
format += `${this.name}: ${this.message}`;
|
|
|
|
return format;
|
|
}
|
|
}
|
|
|
|
// template syntax error with token range, token range converted to source position
|
|
// outside of prepareTemplate
|
|
export class TemplateSyntaxError extends TemplateError {}; |