UNPKG

456 BJavaScriptView Raw
1"use strict";
2
3const fmt = require("simple-fmt");
4const assert = require("assert");
5
6function error(line, var_args) {
7 assert(arguments.length >= 2);
8
9 const msg = (arguments.length === 2 ?
10 String(var_args) : fmt.apply(fmt, Array.prototype.slice.call(arguments, 1)));
11
12 error.errors.push(line === -1 ? msg : fmt("line {0}: {1}", line, msg));
13}
14
15error.reset = function() {
16 error.errors = [];
17};
18
19error.reset();
20
21module.exports = error;