mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Improve consistency of validation error handling
Utilises common path of existing invalidParameterError
This commit is contained in:
@@ -35,7 +35,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
if (is.bool(inputOptions.failOnError)) {
|
||||
inputDescriptor.failOnError = inputOptions.failOnError;
|
||||
} else {
|
||||
throw new Error('Invalid failOnError (boolean) ' + inputOptions.failOnError);
|
||||
throw is.invalidParameterError('failOnError', 'boolean', inputOptions.failOnError);
|
||||
}
|
||||
}
|
||||
// Density
|
||||
@@ -43,7 +43,7 @@ function _createInputDescriptor (input, inputOptions, containerOptions) {
|
||||
if (is.inRange(inputOptions.density, 1, 2400)) {
|
||||
inputDescriptor.density = inputOptions.density;
|
||||
} else {
|
||||
throw new Error('Invalid density (1 to 2400) ' + inputOptions.density);
|
||||
throw is.invalidParameterError('density', 'number between 1 and 2400', inputOptions.density);
|
||||
}
|
||||
}
|
||||
// Raw pixel input
|
||||
|
||||
Reference in New Issue
Block a user