mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 13:23:51 +02:00
Prefix crop validation error messages
This commit is contained in:
+1
-1
@@ -228,7 +228,7 @@ const validateVideoOptions = (videoOptions: ConversionVideoOptions | undefined)
|
|||||||
throw new TypeError('options.video.rotate, when provided, must be 0, 90, 180 or 270.');
|
throw new TypeError('options.video.rotate, when provided, must be 0, 90, 180 or 270.');
|
||||||
}
|
}
|
||||||
if (videoOptions?.crop !== undefined) {
|
if (videoOptions?.crop !== undefined) {
|
||||||
validateCropRectangle(videoOptions.crop);
|
validateCropRectangle(videoOptions.crop, 'options.video.');
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
videoOptions?.frameRate !== undefined
|
videoOptions?.frameRate !== undefined
|
||||||
|
|||||||
+1
-1
@@ -1126,7 +1126,7 @@ export class CanvasSink {
|
|||||||
throw new TypeError('options.rotation, when provided, must be 0, 90, 180 or 270.');
|
throw new TypeError('options.rotation, when provided, must be 0, 90, 180 or 270.');
|
||||||
}
|
}
|
||||||
if (options.crop !== undefined) {
|
if (options.crop !== undefined) {
|
||||||
validateCropRectangle(options.crop);
|
validateCropRectangle(options.crop, 'options.');
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
options.poolSize !== undefined
|
options.poolSize !== undefined
|
||||||
|
|||||||
+7
-7
@@ -580,7 +580,7 @@ export class VideoSample {
|
|||||||
throw new TypeError('options.rotation, when provided, must be 0, 90, 180, or 270.');
|
throw new TypeError('options.rotation, when provided, must be 0, 90, 180, or 270.');
|
||||||
}
|
}
|
||||||
if (options.crop !== undefined) {
|
if (options.crop !== undefined) {
|
||||||
validateCropRectangle(options.crop);
|
validateCropRectangle(options.crop, 'options.');
|
||||||
}
|
}
|
||||||
|
|
||||||
const canvasWidth = context.canvas.width;
|
const canvasWidth = context.canvas.width;
|
||||||
@@ -754,21 +754,21 @@ export const clampCropRectangle = (crop: CropRectangle, outerWidth: number, oute
|
|||||||
assert(crop.height >= 0);
|
assert(crop.height >= 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const validateCropRectangle = (crop: CropRectangle) => {
|
export const validateCropRectangle = (crop: CropRectangle, prefix: string) => {
|
||||||
if (!crop || typeof crop !== 'object') {
|
if (!crop || typeof crop !== 'object') {
|
||||||
throw new TypeError('crop, when provided, must be an object.');
|
throw new TypeError(prefix + 'crop, when provided, must be an object.');
|
||||||
}
|
}
|
||||||
if (!Number.isInteger(crop.left) || crop.left < 0) {
|
if (!Number.isInteger(crop.left) || crop.left < 0) {
|
||||||
throw new TypeError('crop.left must be a non-negative integer.');
|
throw new TypeError(prefix + 'crop.left must be a non-negative integer.');
|
||||||
}
|
}
|
||||||
if (!Number.isInteger(crop.top) || crop.top < 0) {
|
if (!Number.isInteger(crop.top) || crop.top < 0) {
|
||||||
throw new TypeError('crop.top must be a non-negative integer.');
|
throw new TypeError(prefix + 'crop.top must be a non-negative integer.');
|
||||||
}
|
}
|
||||||
if (!Number.isInteger(crop.width) || crop.width < 0) {
|
if (!Number.isInteger(crop.width) || crop.width < 0) {
|
||||||
throw new TypeError('crop.width must be a non-negative integer.');
|
throw new TypeError(prefix + 'crop.width must be a non-negative integer.');
|
||||||
}
|
}
|
||||||
if (!Number.isInteger(crop.height) || crop.height < 0) {
|
if (!Number.isInteger(crop.height) || crop.height < 0) {
|
||||||
throw new TypeError('crop.height must be a non-negative integer.');
|
throw new TypeError(prefix + 'crop.height must be a non-negative integer.');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user