Skip to content

Commit b50caa9

Browse files
committed
fix: handle guard failure in authentication layout
1 parent 7f66889 commit b50caa9

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

‎infrastructure/eid-wallet/src/routes/(auth)/+layout.svelte‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ import { getContext, onMount } from "svelte";
77
let { children } = $props();
88
let isChecking = $state(true);
99
let vaultExists = $state(false);
10+
let guardFailed = $state(false);
11+
1012
const getGlobalState = getContext<() => GlobalState>("globalState");
1113
1214
onMount(async () => {
1315
try {
1416
const globalState = getGlobalState();
1517
if (!globalState) {
1618
console.error("Global state is not defined");
19+
guardFailed = true;
1720
return;
1821
}
1922
@@ -49,6 +52,14 @@ onMount(async () => {
4952

5053
{#if isChecking}
5154
<div class="h-screen w-screen bg-background"></div>
55+
{:else if guardFailed}
56+
<div
57+
class="flex h-screen w-screen items-center justify-center bg-background"
58+
>
59+
<p class="text-center text-sm text-foreground-muted">
60+
An unexpected error occurred. Please restart the application.
61+
</p>
62+
</div>
5263
{:else if !vaultExists}
5364
{@render children()}
5465
{/if}

0 commit comments

Comments
 (0)