-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patherror.js
executable file
·33 lines (30 loc) · 964 Bytes
/
error.js
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
"use strict";
/**
* Create an Error with a message relating to an invalid parameter.
*
* @param {string} name - parameter name.
* @param {string} expected - description of the type/value/range expected.
* @param {*} actual - the value received.
* @returns {TypeError} Containing the formatted message.
* @private
*/
const invalidParameterError = function (name, expected, actual) {
return new TypeError(
`Expected <${expected}> for [${name}] but received ${actual} of type <${typeof actual}>`
);
};
/**
* Create an Error with a message relating to an invalid path.
*
* @param {string} name - parameter name.
* @param {string} path = path string.
* @returns {TypeError} Containing the formatted message.
* @private
*/
const invalidPathError = function (name, path) {
return new TypeError(`${name} path ${path} does not exist.`);
};
module.exports = {
invalidPathError: invalidPathError,
invalidParameterError: invalidParameterError,
};