"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
		});
	}
};
