added a try catch to creating a screenshot

This commit is contained in:
Jack 2020-06-15 01:28:52 +01:00
parent 38bf4c1eef
commit 2dc13e63c5

View file

@ -71,14 +71,18 @@ function copyResultToClipboard() {
y: sourceY - 25
}).then(function(canvas) {
// document.body.appendChild(canvas);
canvas.toBlob(function(blob) {
let data = [new ClipboardItem({ [blob.type]: blob })];
navigator.clipboard.write(data).then(f => {
showNotification('Copied to clipboard',1000);
}).catch(f => {
showNotification('Error saving image to clipboard',2000);
})
});
try{
canvas.toBlob(function(blob) {
let data = [new ClipboardItem({ [blob.type]: blob })];
navigator.clipboard.write(data).then(f => {
showNotification('Copied to clipboard',1000);
}).catch(f => {
showNotification('Error saving image to clipboard',2000);
})
});
}catch(e){
showNotification('Error creating image',2000);
}
});
}