From 3d84eb8f6a2fe31bceb665e7277a104df93469d8 Mon Sep 17 00:00:00 2001 From: Martin Chodur Date: Sun, 7 Apr 2024 00:17:31 +0200 Subject: [PATCH] fix: improve err messages for song imports Signed-off-by: Martin Chodur --- appsscript.json | 4 +++- src/import/import.ts | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/appsscript.json b/appsscript.json index 295eded9..04372a45 100644 --- a/appsscript.json +++ b/appsscript.json @@ -28,7 +28,9 @@ "https://pdfmerge.w69b.com/", "https://api.qrserver.com/", "https://acordes.lacuerda.net/", - "https://www.songbook.fun/" + "https://www.songbook.fun/", + "https://cifraclub.com.br/", + "https://www.cifraclub.com.br/" ] }, "docs": {} diff --git a/src/import/import.ts b/src/import/import.ts index 0c4bc905..eda7c3d0 100644 --- a/src/import/import.ts +++ b/src/import/import.ts @@ -96,6 +96,7 @@ function writeChordsToDocument( } function importUrl(url: string, currentDoc: boolean) { + const errPrefix = "Failed to import chords from " + url + ": "; const supportedSites = getSupportedChordsImportSites(); let chords: chordSiteData; let matchingSite: importSite | null = null; @@ -109,19 +110,20 @@ function importUrl(url: string, currentDoc: boolean) { } if (matchingSite === null) { - throw Error("Unsupported site for import."); + throw Error( + errPrefix + + "Unsupported site, if you would like to import chords from this site, please contact the developer." + ); } try { chords = matchingSite.processor(url); } catch (e) { - throw Error( - "Failed to import data from " + matchingSite.domain + ": " + e.message - ); + throw Error(errPrefix + e.message); } if (chords === null || chords.rows.length === 0) { - throw Error("Import error: No chords found."); + throw Error(errPrefix + "No chords found."); } let targetDoc = DocumentApp.getActiveDocument();