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:
@@ -72,7 +72,7 @@ function extractChannel (channel) {
|
||||
if (is.integer(channel) && is.inRange(channel, 0, 4)) {
|
||||
this.options.extractChannel = channel;
|
||||
} else {
|
||||
throw new Error('Cannot extract invalid channel ' + channel);
|
||||
throw is.invalidParameterError('channel', 'integer or one of: red, green, blue', channel);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -124,7 +124,7 @@ function bandbool (boolOp) {
|
||||
if (is.string(boolOp) && is.inArray(boolOp, ['and', 'or', 'eor'])) {
|
||||
this.options.bandBoolOp = boolOp;
|
||||
} else {
|
||||
throw new Error('Invalid bandbool operation ' + boolOp);
|
||||
throw is.invalidParameterError('boolOp', 'one of: and, or, eor', boolOp);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user