fix(ui): canvasToBlob not raising error correctly

This commit is contained in:
psychedelicious 2024-08-30 22:02:14 +10:00
parent 48edb6e023
commit 4e74006c5f

View File

@ -302,10 +302,13 @@ export const konvaNodeToCanvas = (node: Konva.Node, bbox?: Rect): HTMLCanvasElem
* @returns A Promise that resolves with Blob of the node cropped to the bounding box
*/
export const canvasToBlob = (canvas: HTMLCanvasElement): Promise<Blob> => {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
canvas.toBlob((blob) => {
assert(blob, 'blob is null');
if (!blob) {
reject('Failed to convert canvas to blob');
} else {
resolve(blob);
}
});
});
};