Skip to content

Commit 8e8fc17

Browse files
committed
simplify check to 404 status
1 parent a9853b3 commit 8e8fc17

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

packages/sveltekit/src/client/handleError.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,8 @@ type SafeHandleServerErrorInput = Omit<HandleClientErrorInput, 'status' | 'messa
3030
*/
3131
export function handleErrorWithSentry(handleError: HandleClientError = defaultErrorHandler): HandleClientError {
3232
return (input: SafeHandleServerErrorInput): ReturnType<HandleClientError> => {
33-
const { status, message } = input;
34-
const isNotFoundError = status === 404 && message === 'Not Found';
35-
36-
if (!isNotFoundError) {
33+
// SvelteKit 2.0 offers a reliable way to check for a 404 error:
34+
if (input.status !== 404) {
3735
captureException(input.error, {
3836
mechanism: {
3937
type: 'sveltekit',

packages/sveltekit/test/client/handleError.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('handleError', () => {
6262
});
6363
});
6464

65-
it('doesn\'t capture "Not Found" errors', async () => {
65+
it("doesn't capture 404 errors", async () => {
6666
const wrappedHandleError = handleErrorWithSentry(handleError);
6767
const returnVal = (await wrappedHandleError({
6868
error: new Error('404 Not Found'),

0 commit comments

Comments
 (0)