Skip to content

Conversation

@Reversean
Copy link
Member

@Reversean Reversean commented Dec 24, 2025

Closes #137

Added error triggers in svelte playground for testing HawkCatcher integration.

recording_2025-12-24_15.22.21.mp4

@Reversean Reversean changed the base branch from master to feature/svelte-integration-playground December 24, 2025 12:38
@Reversean Reversean changed the base branch from feature/svelte-integration-playground to feature/svelte-playground-hawk-catcher December 24, 2025 12:50
@Reversean Reversean force-pushed the feature/svelte-playground-error-triggers branch from a240f51 to 505a928 Compare December 24, 2025 12:52
@Reversean Reversean force-pushed the feature/svelte-playground-hawk-catcher branch from 779f6f4 to fb8bc3b Compare December 24, 2025 12:58
@Reversean Reversean force-pushed the feature/svelte-playground-error-triggers branch from 505a928 to 9def40f Compare December 24, 2025 12:58
@Reversean Reversean linked an issue Dec 24, 2025 that may be closed by this pull request
7 tasks
@Reversean Reversean force-pushed the feature/svelte-playground-hawk-catcher branch 3 times, most recently from 70da4c7 to 5bbf3cf Compare December 26, 2025 13:40
@Reversean Reversean force-pushed the feature/svelte-playground-error-triggers branch 2 times, most recently from 477c1ce to 58e8757 Compare December 26, 2025 15:40
@Reversean Reversean force-pushed the feature/svelte-playground-hawk-catcher branch from 5bbf3cf to f31904c Compare December 27, 2025 20:55
@Reversean Reversean force-pushed the feature/svelte-playground-error-triggers branch from 58e8757 to 41876c0 Compare December 27, 2025 20:57
@Reversean Reversean marked this pull request as draft December 29, 2025 21:26
@neSpecc neSpecc changed the title Svelte playground error triggers 3 - Svelte playground - add more error triggers Jan 14, 2026
@Reversean Reversean force-pushed the feature/svelte-playground-hawk-catcher branch 2 times, most recently from 9f69024 to b2a5df0 Compare January 14, 2026 22:32
@Reversean Reversean force-pushed the feature/svelte-playground-error-triggers branch from 41876c0 to 7febdcd Compare January 14, 2026 22:39
@Reversean Reversean marked this pull request as ready for review January 20, 2026 19:43
@Reversean Reversean force-pushed the feature/svelte-playground-error-triggers branch from 7febdcd to 1812102 Compare January 22, 2026 18:44
@FeironoX5 FeironoX5 self-requested a review January 24, 2026 19:51
@@ -0,0 +1,9 @@
<script lang="ts">
let { shouldError }: { shouldError: boolean } = $props();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need in $props() & if statement, just do throw

</div>
{/snippet}

<svelte:boundary onerror={handleBoundaryError} failed={fallback}>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rendering error report request is not being sent to Hawk Tracker because it intercepted by both onerror and failed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

let showError = $state(false);
function triggerError() {
showError = true;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider open/close behaviour with showError = !showError

Comment on lines 3 to 7
if (import.meta.env.VITE_HAWK_TOKEN) {
new Hawk({
token: import.meta.env.VITE_HAWK_TOKEN,
});
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.


Example usage:

```svelte

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just so we don't forget to change this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Svelte playground project Svelte/SvelteKit integration package

4 participants