From 211b0cbe9b83a76997bc7ce0a3272e2bdb0c5fa0 Mon Sep 17 00:00:00 2001 From: KevinWh0 <45321184+KevinWh0@users.noreply.github.com> Date: Mon, 4 Mar 2024 16:54:35 +0100 Subject: [PATCH 1/3] fixed it with a try catch --- packages/frontend/src/boot/main-boot.ts | 43 +++++++++++++------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts index 66d9bf0680..b9bd62baed 100644 --- a/packages/frontend/src/boot/main-boot.ts +++ b/packages/frontend/src/boot/main-boot.ts @@ -73,27 +73,30 @@ export async function mainBoot() { mainRouter.push('/search'); }, }; - - if (defaultStore.state.enableSeasonalScreenEffect) { - const month = new Date().getMonth() + 1; - if (defaultStore.state.hemisphere === 'S') { - // â–¼å—åŠçƒ - if (month === 7 || month === 8) { - const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; - new SnowfallEffect({}).render(); - } - } else { - // ▼北åŠçƒ - if (month === 12 || month === 1) { - const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; - new SnowfallEffect({}).render(); - } else if (month === 3 || month === 4) { - const SakuraEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; - new SakuraEffect({ - sakura: true, - }).render(); + try { + if (defaultStore.state.enableSeasonalScreenEffect) { + const month = new Date().getMonth() + 1; + if (defaultStore.state.hemisphere === 'S') { + // â–¼å—åŠçƒ + if (month === 7 || month === 8) { + const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; + new SnowfallEffect({}).render(); + } + } else { + // ▼北åŠçƒ + if (month === 12 || month === 1) { + const SnowfallEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; + new SnowfallEffect({}).render(); + } else if (month === 3 || month === 4) { + const SakuraEffect = (await import('@/scripts/snowfall-effect.js')).SnowfallEffect; + new SakuraEffect({ + sakura: true, + }).render(); + } } - } + } + } catch (error) { + console.error(error); } if ($i) { -- GitLab From dad6f9ba1c3ff3cca75ddde2c97d0a18b6c1642a Mon Sep 17 00:00:00 2001 From: KevinWh0 <45321184+KevinWh0@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:20:18 +0100 Subject: [PATCH 2/3] added a more specific error message --- packages/frontend/src/boot/main-boot.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/boot/main-boot.ts b/packages/frontend/src/boot/main-boot.ts index b9bd62baed..f71a26dfce 100644 --- a/packages/frontend/src/boot/main-boot.ts +++ b/packages/frontend/src/boot/main-boot.ts @@ -96,7 +96,8 @@ export async function mainBoot() { } } } catch (error) { - console.error(error); + // console.error(error); + console.error('Failed to initialise the seasonal screen effect canvas context:', error); } if ($i) { -- GitLab From 5a09acdb8dcf7c0784a3fc11342f83b669356287 Mon Sep 17 00:00:00 2001 From: KevinWh0 <45321184+KevinWh0@users.noreply.github.com> Date: Mon, 4 Mar 2024 18:05:25 +0100 Subject: [PATCH 3/3] added jsdoc for snowfall effect throws --- packages/frontend/src/scripts/snowfall-effect.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/frontend/src/scripts/snowfall-effect.ts b/packages/frontend/src/scripts/snowfall-effect.ts index 11fcaa0716..d88bdb6660 100644 --- a/packages/frontend/src/scripts/snowfall-effect.ts +++ b/packages/frontend/src/scripts/snowfall-effect.ts @@ -155,7 +155,9 @@ export class SnowfallEffect { max: 0.125, easing: 0.0005, }; - + /** + * @throws {Error} - Thrown when it fails to get WebGL context for the canvas + */ constructor(options: { sakura?: boolean; }) { -- GitLab