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..d5ad86c4b 100644 --- a/ts/lib/components/ErrorPage.svelte +++ b/ts/lib/components/ErrorPage.svelte @@ -2,17 +2,42 @@ 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..704d3d132 100644 --- a/ts/lib/generated/post.ts +++ b/ts/lib/generated/post.ts @@ -41,7 +41,8 @@ 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;