diff --git a/CONTRIBUTORS b/CONTRIBUTORS index d90b7dbcc..c8ecec8d5 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -251,6 +251,7 @@ Matbe766 Amanda Sternberg arold0 nav1s +medProgAyat Ranjit Odedra Eltaurus jariji diff --git a/ftl/core/importing.ftl b/ftl/core/importing.ftl index b23d12654..891c5e05d 100644 --- a/ftl/core/importing.ftl +++ b/ftl/core/importing.ftl @@ -160,7 +160,7 @@ importing-cards-added = [one] { $count } card added. *[other] { $count } cards added. } -importing-file-empty = The file you selected is empty. +importing-file-empty = The selected file is empty. Please choose a valid file. importing-notes-added = { $count -> [one] { $count } new note imported. diff --git a/ts/lib/components/ErrorPage.svelte b/ts/lib/components/ErrorPage.svelte index 01bcb1224..eaacb359e 100644 --- a/ts/lib/components/ErrorPage.svelte +++ b/ts/lib/components/ErrorPage.svelte @@ -2,17 +2,45 @@ Copyright: Ankitects Pty Ltd and contributors License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html --> + -
- {error.message} +
+

{error.message}

+
diff --git a/ts/lib/generated/post.ts b/ts/lib/generated/post.ts index 90e372520..0ed02549c 100644 --- a/ts/lib/generated/post.ts +++ b/ts/lib/generated/post.ts @@ -19,7 +19,9 @@ export async function postProto( return outputType.fromBinary(outputBytes); } catch (err) { const { alertOnError = true } = options; - if (alertOnError && !(err instanceof Error && err.message === "500: Interrupted")) { + if ( + alertOnError && !(err instanceof Error && err.message === "500: Interrupted") + ) { alert(err); } throw err; @@ -41,7 +43,12 @@ async function postProtoInner(url: string, body: Uint8Array): Promise - +{#if data.initialError} + +{:else} + +{/if} diff --git a/ts/routes/import-csv/[...path]/+page.ts b/ts/routes/import-csv/[...path]/+page.ts index cda2bace9..2f947f791 100644 --- a/ts/routes/import-csv/[...path]/+page.ts +++ b/ts/routes/import-csv/[...path]/+page.ts @@ -6,14 +6,19 @@ import { ImportCsvState } from "../lib"; import type { PageLoad } from "./$types"; export const load = (async ({ params }) => { - const [notetypes, decks, metadata] = await Promise.all([ - getNotetypeNames({}), - getDeckNames({ - skipEmptyDefault: false, - includeFiltered: false, - }), - getCsvMetadata({ path: params.path }, { alertOnError: false }), - ]); - const state = new ImportCsvState(params.path, notetypes, decks, metadata); - return { state }; + try { + const [notetypes, decks, metadata] = await Promise.all([ + getNotetypeNames({}), + getDeckNames({ + skipEmptyDefault: false, + includeFiltered: false, + }), + getCsvMetadata({ path: params.path }, { alertOnError: false }), + ]); + const state = new ImportCsvState(params.path, notetypes, decks, metadata); + return { state }; + } catch (error: any) { + const rawMsg = error?.message ?? String(error ?? ""); + return { initialError: new Error(rawMsg) }; + } }) satisfies PageLoad;