From: Martin Pitt Date: Wed, 23 Sep 2026 20:54:19 +0000 (+0200) Subject: Show load errors on the page X-Git-Url: https://piware.de/gitweb/?a=commitdiff_plain;h=b1f6f311e4abda7cdb9eca9d7f1af37c512ef88c;p=chordpro-web.git Show load errors on the page 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. --- diff --git a/chordpro-web.js b/chordpro-web.js index cfac467..f24ca37 100644 --- a/chordpro-web.js +++ b/chordpro-web.js @@ -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}`; } }