feat(observability): guard navigator.clipboard and handle rejection in copyId
Adds availability guard (navigator.clipboard may be undefined in non-HTTPS contexts) and a rejection handler so clipboard-denied errors are silently caught rather than becoming unhandled promise rejections. Tests cover the success feedback and the silent-failure path. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,10 +7,16 @@ let copied = $state(false);
|
||||
function copyId() {
|
||||
const id = page.error?.errorId;
|
||||
if (!id) return;
|
||||
navigator.clipboard.writeText(id).then(() => {
|
||||
copied = true;
|
||||
setTimeout(() => (copied = false), 2000);
|
||||
});
|
||||
if (!navigator.clipboard) return;
|
||||
navigator.clipboard.writeText(id).then(
|
||||
() => {
|
||||
copied = true;
|
||||
setTimeout(() => (copied = false), 2000);
|
||||
},
|
||||
() => {
|
||||
/* clipboard denied or unavailable — select-all on the <code> element remains */
|
||||
}
|
||||
);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user