Skip to content

feat(sveltekit): Add server-side handleError wrapper - #7411

Merged
AbhiPrasad merged 3 commits into
developfrom
abhi-sveltekit-server-handle-error
Mar 10, 2023
Merged

feat(sveltekit): Add server-side handleError wrapper#7411
AbhiPrasad merged 3 commits into
developfrom
abhi-sveltekit-server-handle-error

Conversation

@AbhiPrasad

@AbhiPrasadAbhiPrasad commented Mar 10, 2023

Copy link
Copy Markdown
Contributor

ref #7403

Adds a wrapper for the server-side handleError hook.

Usage is like the following:

src/hooks.server.js

import{handleErrorWithSentry}from'@sentry/sveltekit';/** @type {import('@sveltejs/kit').HandleServerError} */functionmyCustomHandleError(){
...
}// myCustomHandleError is optionalexportconsthandleError=handleErrorWithSentry(myCustomHandleError);

In #7406 I introduced this functionality on the client side.

@github-actions

github-actionsBot commented Mar 10, 2023

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize
@sentry/browser - ES5 CDN Bundle (gzipped + minified)20.24 KB (+0.11% 🔺)
@sentry/browser - ES5 CDN Bundle (minified)62.95 KB (+0.11% 🔺)
@sentry/browser - ES6 CDN Bundle (gzipped + minified)18.87 KB (+0.1% 🔺)
@sentry/browser - ES6 CDN Bundle (minified)55.87 KB (+0.12% 🔺)
@sentry/browser - Webpack (gzipped + minified)20.62 KB (+0.12% 🔺)
@sentry/browser - Webpack (minified)67.39 KB (+0.1% 🔺)
@sentry/react - Webpack (gzipped + minified)20.65 KB (+0.12% 🔺)
@sentry/nextjs Client - Webpack (gzipped + minified)48.54 KB (+0.18% 🔺)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified)27.51 KB (+0.23% 🔺)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified)25.76 KB (+0.21% 🔺)
@sentry/replay ES6 CDN Bundle (gzipped + minified)43.17 KB (0%)
@sentry/replay - Webpack (gzipped + minified)37.19 KB (0%)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified)61.18 KB (+0.09% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified)54.35 KB (+0.04% 🔺)

@AbhiPrasad

Copy link
Copy Markdown
ContributorAuthor

In e9d8904 I added two additional changes

  1. Renamed wrapHandleErrorWithSentry to handleErrorWithSentry
  2. Made the passing of a custom handleError implementation optional

@Lms24Lms24 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Great work! 🔥

import type { HandleClientError, NavigationEvent } from '@sveltejs/kit';

import { wrapHandleError } from '../../src/client/handleError';
import { wrapHandleErrorWithSentry } from '../../src/client/handleError';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

l: this needs to be updated I guess 😅

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

yes! good catch.

@AbhiPrasad
AbhiPrasad merged commit ed1347e into developMar 10, 2023
@AbhiPrasad
AbhiPrasad deleted the abhi-sveltekit-server-handle-error branch March 10, 2023 14:42
Sign up for freeto 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.

2 participants

@AbhiPrasad@Lms24