You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openNG/build/core/errors/syntax-error.js

26 lines
781 B
JavaScript

"use strict";
const errors = require("./errors");
module.exports = function createSyntaxError({line, column, error}) {
if (line == null) {
throw new Error("Must specify a line number");
} else if (column == null) {
throw new Error("Must specify a column number");
} else if (error == null) {
throw new Error("Must specify what caused the syntax error");
} else if (typeof line !== "number") {
throw new Error("Line number must be numeric");
} else if (typeof column !== "number") {
throw new Error("Column number must be numeric");
} else if (typeof error !== "string") {
throw new Error("Syntax error cause must be a string");
} else {
return new errors.SyntaxError("A syntax error occurred", {
line: line,
column: column,
error: error
});
}
};