]> piware.de Git - chordpro-web.git/commitdiff
Show load errors on the page
authorMartin Pitt <martin@piware.de>
Wed, 23 Sep 2026 20:54:19 +0000 (22:54 +0200)
committerMartin Pitt <martin@piware.de>
Wed, 23 Sep 2026 20:55:25 +0000 (22:55 +0200)
A failed fetch of the URL from the l parameter only warned on the console,
leaving the user with "No file loaded" and no hint why.

chordpro-web.js

index cfac467d8bf591a3c028ced7cb1b9a3a59086716..f24ca37ca6566eb9932a9aca960f829eada730c1 100644 (file)
@@ -81,12 +81,10 @@ const loadURL = new URL(location).searchParams.get('l');
 if (loadURL) {
     try {
         const response = await fetch(loadURL);
-        if (response.ok) {
-            renderChordpro(await response.text());
-        } else {
-            console.warn('Failed to fetch', loadURL, ':', response.status, response.statusText);
-        }
+        if (!response.ok)
+            throw new Error(`${response.status} ${response.statusText}`);
+        renderChordpro(await response.text());
     } catch (error) {
-        console.warn('Failed to fetch', loadURL, ':', error);
+        document.getElementById('title').textContent = `Failed to load ${loadURL}: ${error.message}`;
     }
 }