From b1f6f311e4abda7cdb9eca9d7f1af37c512ef88c Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 23 Sep 2026 22:54:19 +0200 Subject: [PATCH] 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. --- chordpro-web.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) 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}`; } } -- 2.47.3