all files / es6/ errors.js

100% Statements 26/26
100% Branches 0/0
100% Functions 5/5
100% Lines 26/26
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49        23× 23× 23×                                      
"use strict";
 
function XTError(message) {
	this.name = "GenericError";
	this.message = message;
	this.stack = (new Error(message)).stack;
}
XTError.prototype = Error.prototype;
 
function XTTemplateError(message) {
	this.name = "TemplateError";
	this.message = message;
	this.stack = (new Error(message)).stack;
}
XTTemplateError.prototype = new XTError();
 
function XTScopeParserError(message) {
	this.name = "ScopeParserError";
	this.message = message;
	this.stack = (new Error(message)).stack;
}
XTScopeParserError.prototype = new XTError();
 
function XTInternalError(message) {
	this.name = "InternalError";
	this.properties = {explanation: "InternalError"};
	this.message = message;
	this.stack = (new Error(message)).stack;
}
XTInternalError.prototype = new XTError();
 
function throwMultiError(errors) {
	const err = new XTTemplateError("Multi error");
	err.properties = {
		errors,
		id: "multi_error",
		explanation: "The template has multiple errors",
	};
	throw err;
}
 
module.exports = {
	XTError,
	XTTemplateError,
	XTInternalError,
	XTScopeParserError,
	throwMultiError,
};