Expand .raise() to allow more options.

This commit is contained in:
Logan Smyth 2018-03-03 13:10:58 -08:00
parent aa669ef902
commit 5c3092d86f
2 changed files with 7 additions and 3 deletions

View File

@ -13,7 +13,11 @@ export default class LocationParser extends CommentsParser {
raise(
pos: number,
message: string,
{
missingPluginNames,
}: {
missingPluginNames?: Array<string>,
} = {},
): empty {
const loc = getLineInfo(this.input, pos);
message += ` (${loc.line}:${loc.column})`;

View File

@ -120,7 +120,7 @@ export default class UtilParser extends Tokenizer {
throw this.raise(
pos != null ? pos : this.state.start,
`This experimental syntax requires enabling the parser plugin: '${name}'`,
[name],
{ missingPluginNames: [name] },
);
}
@ -134,7 +134,7 @@ export default class UtilParser extends Tokenizer {
`This experimental syntax requires enabling one of the following parser plugin(s): '${names.join(
", ",
)}'`,
names,
{ missingPluginNames: names },
);
}
}