Skip to content

Commit caa0673

Browse files
Handle failed markdown copy fetches
Co-authored-by: GreenFlux <GreenFlux@users.noreply.github.com>
1 parent ce9fc93 commit caa0673

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

docs/src/components/PageSidebar.astro

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,13 @@ const actions = [
159159
btn.addEventListener('click', async () => {
160160
btn.disabled = true;
161161
try {
162-
const res = await fetch(`${path}.md`);
162+
const markdownUrl = `${path}.md`;
163+
const res = await fetch(markdownUrl);
164+
165+
if (!res.ok) {
166+
throw new Error(`Failed to fetch ${markdownUrl}: ${res.status} ${res.statusText}`);
167+
}
168+
163169
const text = await res.text();
164170
await navigator.clipboard.writeText(text);
165171
btn.classList.add('copied');

0 commit comments

Comments
 (0)