3 - Svelte playground - add more error triggers#143
3 - Svelte playground - add more error triggers#143
Conversation
a240f51 to
505a928
Compare
779f6f4 to
fb8bc3b
Compare
505a928 to
9def40f
Compare
70da4c7 to
5bbf3cf
Compare
477c1ce to
58e8757
Compare
5bbf3cf to
f31904c
Compare
58e8757 to
41876c0
Compare
9f69024 to
b2a5df0
Compare
41876c0 to
7febdcd
Compare
7febdcd to
1812102
Compare
| @@ -0,0 +1,9 @@ | |||
| <script lang="ts"> | |||
| let { shouldError }: { shouldError: boolean } = $props(); | |||
There was a problem hiding this comment.
No need in $props() & if statement, just do throw
There was a problem hiding this comment.
Removed redundant props and if.
| </div> | ||
| {/snippet} | ||
|
|
||
| <svelte:boundary onerror={handleBoundaryError} failed={fallback}> |
There was a problem hiding this comment.
Rendering error report request is not being sent to Hawk Tracker because it intercepted by both onerror and failed.
There was a problem hiding this comment.
The approach here will be to implement customErrorHandler() and change handleBoundaryError() like this:
./+page.svelte:
function handleBoundaryError(error: Error) {
console.error('🟡 [svelte:boundary] Caught rendering error:', error);
customErrorHandler(error);
}
../../../hawk-related:
export let customErrorHandler: (message: Error | string) => void = (message): void => console.error(message);
...(see hoooks.client.ts review)
There was a problem hiding this comment.
I think it should be changed later after catcher server integration.
| let showError = $state(false); | ||
|
|
||
| function triggerError() { | ||
| showError = true; |
There was a problem hiding this comment.
Consider open/close behaviour with showError = !showError
| if (import.meta.env.VITE_HAWK_TOKEN) { | ||
| new Hawk({ | ||
| token: import.meta.env.VITE_HAWK_TOKEN, | ||
| }); | ||
| } |
There was a problem hiding this comment.
If implementing customErrorHandler() consider moving this part to ../../../hawk-related & wrapping like this so it could reassign customErrorHandler():
export const initHawk: () => void = () => {
onMount(() => {
if (browser && typeof localStorage !== 'undefined') {
if (import.meta.env.VITE_HAWK_TOKEN) {
const hawk = new Hawk({
token: import.meta.env.VITE_HAWK_TOKEN,
});
customErrorHandler = (message) => hawk.send(message);
}
}
});
};
Call initHawk() in script section of src/+layout.svelte as Hawk uses localStorage API available in browser enviroment only & sveltekit trying to do SSR.
There was a problem hiding this comment.
I think it should be changed later after catcher server integration.
|
|
||
| Example usage: | ||
|
|
||
| ```svelte |
There was a problem hiding this comment.
Just so we don't forget to change this
b2a5df0 to
c191c75
Compare
1812102 to
9f22086
Compare
c191c75 to
962ad7d
Compare
7e4094b to
d4dd121
Compare
962ad7d to
0b86664
Compare
d4dd121 to
182516f
Compare
32d0d52 to
3a95c1d
Compare
182516f to
976c00b
Compare
976c00b to
0551642
Compare
6617730 to
619710c
Compare
Add resolve.conditions: ['source'] to vite and vitest configs so workspace deps are resolved from TypeScript source instead of dist. This allows build:modified and test:modified to run against changed packages without requiring their deps to be pre-built. - packages/javascript: - bundle @hawk.so/core instead of externalizing it - move @hawk.so/core to devDependencies - add AGPL-3.0-only to license allow list - add ssr.resolve.conditions for Vite 7 node/SSR environment - packages/sveltekit: - add resolve.conditions: ['source'] - packages/sveltekit/playground: - add resolve.conditions: ['source']
619710c to
4377224
Compare
…sveltekit playground
Closes #137
Added error triggers in svelte playground for testing
HawkCatcherintegration.recording_2025-12-24_15.22.21.mp4