Skip to content

Commit 1934041

Browse files
committed
Fix error handling for clipboard access
1 parent 861bd49 commit 1934041

1 file changed

Lines changed: 15 additions & 10 deletions

File tree

src/functions.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2561,8 +2561,9 @@ function edit_copy(execCommandFallback) {
25612561
if (execCommandFallback) {
25622562
return try_exec_command("copy");
25632563
} else {
2564-
throw new Error(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2565-
// throw new Error(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2564+
show_error_message(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2565+
// show_error_message(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2566+
return;
25662567
}
25672568
}
25682569
navigator.clipboard.writeText(text);
@@ -2571,8 +2572,9 @@ function edit_copy(execCommandFallback) {
25712572
if (execCommandFallback) {
25722573
return try_exec_command("copy");
25732574
} else {
2574-
throw new Error(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2575-
// throw new Error(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2575+
show_error_message(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2576+
// show_error_message(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2577+
return;
25762578
}
25772579
}
25782580
selection.canvas.toBlob(blob => {
@@ -2599,8 +2601,9 @@ function edit_cut(execCommandFallback) {
25992601
if (execCommandFallback) {
26002602
return try_exec_command("cut");
26012603
} else {
2602-
throw new Error(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2603-
// throw new Error(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2604+
show_error_message(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2605+
// show_error_message(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2606+
return;
26042607
}
26052608
}
26062609
edit_copy();
@@ -2621,8 +2624,9 @@ async function edit_paste(execCommandFallback) {
26212624
if (execCommandFallback) {
26222625
return try_exec_command("paste");
26232626
} else {
2624-
throw new Error(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2625-
// throw new Error(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2627+
show_error_message(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2628+
// show_error_message(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2629+
return;
26262630
}
26272631
}
26282632
const clipboardText = await navigator.clipboard.readText();
@@ -2633,8 +2637,9 @@ async function edit_paste(execCommandFallback) {
26332637
if (execCommandFallback) {
26342638
return try_exec_command("paste");
26352639
} else {
2636-
throw new Error(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2637-
// throw new Error(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2640+
show_error_message(`${localize("Error getting the Clipboard Data!")} ${recommendationForClipboardAccess}`);
2641+
// show_error_message(`The Async Clipboard API is not supported by this browser. ${browserRecommendationForClipboardAccess}`);
2642+
return;
26382643
}
26392644
}
26402645
try {

0 commit comments

Comments
 (0)