Skip to content

Commit 51788bc

Browse files
committed
only check status
1 parent 44abc21 commit 51788bc

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

packages/sveltekit/src/server/handleError.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,12 @@ export function handleErrorWithSentry(handleError: HandleServerError = defaultEr
5353

5454
/**
5555
* When a page request fails because the page is not found, SvelteKit throws a "Not found" error.
56-
* In the error handler here, we can't access the response yet (which we do in the load instrumentation),
57-
* so we have to check if the error is a "Not found" error by checking if the route id is missing and
58-
* by checking the error message on top of the raw stack trace.
5956
*/
6057
function isNotFoundError(input: SafeHandleServerErrorInput): boolean {
61-
const { error, event, status, message } = input;
58+
const { error, event, status } = input;
6259

6360
// SvelteKit 2.0 offers a reliable way to check for a Not Found error:
64-
if (status === 404 && message === 'Not Found') {
61+
if (status === 404) {
6562
return true;
6663
}
6764

packages/sveltekit/test/server/handleError.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('handleError', () => {
2626
consoleErrorSpy.mockClear();
2727
});
2828

29-
it('doesn\'t capture "Not found" errors for incorrect navigations', async () => {
29+
it('doesn\'t capture "Not found" errors for incorrect navigations [Kit 1.x]', async () => {
3030
const wrappedHandleError = handleErrorWithSentry();
3131
const mockError = new Error('Not found: /asdf/123');
3232
const mockEvent = {
@@ -43,7 +43,7 @@ describe('handleError', () => {
4343
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
4444
});
4545

46-
it('doesn\'t capture "Not found" errors for incorrect navigations', async () => {
46+
it('doesn\'t capture "Not found" errors for incorrect navigations [Kit 2.x]', async () => {
4747
const wrappedHandleError = handleErrorWithSentry();
4848

4949
const returnVal = await wrappedHandleError({

0 commit comments

Comments
 (0)