my website at ewancroft.uk
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(layout): add global error and promise rejection handlers on mount

+22
+22
src/routes/+layout.svelte
··· 4 4 import { MetaTags } from '$lib/components/seo'; 5 5 import { createSiteMeta, type SiteMetadata } from '$lib/helper/siteMeta'; 6 6 import type { Snippet } from 'svelte'; 7 + import { onMount } from 'svelte'; 7 8 8 9 interface Props { 9 10 data: { ··· 15 16 16 17 // Use $props() instead of export let in Svelte 5 runes mode 17 18 let { data, children }: Props = $props(); 19 + 20 + onMount(() => { 21 + console.info('[App] Application mounted'); 22 + 23 + // Setup global error handler 24 + window.onerror = (msg, url, lineNo, columnNo, error) => { 25 + console.error('[App] Global error:', { 26 + message: msg, 27 + url, 28 + lineNo, 29 + columnNo, 30 + error 31 + }); 32 + return false; 33 + }; 34 + 35 + // Setup unhandled promise rejection handler 36 + window.onunhandledrejection = (event) => { 37 + console.error('[App] Unhandled promise rejection:', event.reason); 38 + }; 39 + }); 18 40 19 41 // Reactive meta updates on navigation 20 42 let headMeta = $derived(createSiteMeta({