From 1d15ec644d80de9ce605e83665cbd6191af5f7ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20M=C3=A4hr?= Date: Fri, 11 Oct 2024 22:10:41 +0200 Subject: [PATCH] fix: add error logging for download failures and page loading issues --- src/lib/downloadManager.mjs | 3 ++- src/routes/+page.js | 1 + src/routes/[slug]/+page.js | 1 + src/routes/blog/[slug]/+page.js | 1 + src/routes/blog/kategorie/[slug]/+page.js | 1 + src/routes/partner/+page.svelte | 1 + 6 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/downloadManager.mjs b/src/lib/downloadManager.mjs index 2fd23cdb..3c11fb33 100644 --- a/src/lib/downloadManager.mjs +++ b/src/lib/downloadManager.mjs @@ -93,8 +93,9 @@ class DownloadManager { if (!response.ok) throw new Error(`Failed to fetch ${url}: ${response.statusText}`); await pipelineAsync(response.body, fs.createWriteStream(path.join(outputPath, fileName))); console.log(`Downloaded ${url} to ${path.join(outputPath, fileName)}`); - } catch (error) { + } catch (e) { if (retries > 0) { + console.error(e); console.log(`Retrying download for ${url}. Retries left: ${retries - 1}`); await this.download(url, staticDir, retries - 1); } else { diff --git a/src/routes/+page.js b/src/routes/+page.js index 25e15626..7ca762e2 100644 --- a/src/routes/+page.js +++ b/src/routes/+page.js @@ -10,6 +10,7 @@ export async function load() { meta: page.metadata }; } catch (e) { + console.error(e); error(404, `Could not find startseite.md`); } } diff --git a/src/routes/[slug]/+page.js b/src/routes/[slug]/+page.js index 94988bef..170a0afd 100644 --- a/src/routes/[slug]/+page.js +++ b/src/routes/[slug]/+page.js @@ -10,6 +10,7 @@ export async function load({ params }) { meta: page.metadata }; } catch (e) { + console.error(e); error(404, `Could not find ${params.slug}`); } } diff --git a/src/routes/blog/[slug]/+page.js b/src/routes/blog/[slug]/+page.js index 2d4a0632..474e2856 100644 --- a/src/routes/blog/[slug]/+page.js +++ b/src/routes/blog/[slug]/+page.js @@ -10,6 +10,7 @@ export async function load({ params }) { meta: post.metadata }; } catch (e) { + console.error(e); error(404, `Could not find ${params.slug}`); } } diff --git a/src/routes/blog/kategorie/[slug]/+page.js b/src/routes/blog/kategorie/[slug]/+page.js index 7a280b73..ade6cdc1 100644 --- a/src/routes/blog/kategorie/[slug]/+page.js +++ b/src/routes/blog/kategorie/[slug]/+page.js @@ -13,6 +13,7 @@ export async function load({ fetch, params }) { posts: filteredPosts }; } catch (e) { + console.error(e); error(404, `Could not find ${params.slug}`); } } diff --git a/src/routes/partner/+page.svelte b/src/routes/partner/+page.svelte index fc45370b..4a7842e5 100644 --- a/src/routes/partner/+page.svelte +++ b/src/routes/partner/+page.svelte @@ -24,6 +24,7 @@ label: feature.properties.label, name: feature.properties.name })); + // eslint-disable-next-line no-unused-vars let selectedFeature = null; function flyToFeature(feature, zoomLevel = 18) {