mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Improve error messages for invalid resize parameters
Dependency version bumps and doc refresh
This commit is contained in:
18
lib/is.js
18
lib/is.js
@@ -80,6 +80,21 @@ const inArray = function (val, list) {
|
||||
return list.indexOf(val) !== -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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 {Error} Containing the formatted message.
|
||||
* @private
|
||||
*/
|
||||
const invalidParameterError = function (name, expected, actual) {
|
||||
return new Error(
|
||||
`Expected ${expected} for ${name} but received ${actual} of type ${typeof actual}`
|
||||
);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
defined: defined,
|
||||
object: object,
|
||||
@@ -90,5 +105,6 @@ module.exports = {
|
||||
number: number,
|
||||
integer: integer,
|
||||
inRange: inRange,
|
||||
inArray: inArray
|
||||
inArray: inArray,
|
||||
invalidParameterError: invalidParameterError
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user