Skip to content

Commit

Permalink
fix: log whole error object in default handleError (#9791)
Browse files Browse the repository at this point in the history
closes #9785

People may have custom errors without a stack and logging just the stack as a string misses out on some pretty terminal formatting from node, along with stuff like Error.cause.
  • Loading branch information
gtm-nayan authored Apr 28, 2023
1 parent 033cc0b commit 789f4c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/tender-cows-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

fix: log whole error object in default handleError
6 changes: 2 additions & 4 deletions packages/kit/src/runtime/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ export class Server {

this.#options.hooks = {
handle: module.handle || (({ event, resolve }) => resolve(event)),
// @ts-expect-error
handleError: module.handleError || (({ error }) => console.error(error?.stack)),
handleError: module.handleError || (({ error }) => console.error(error)),
handleFetch: module.handleFetch || (({ request, fetch }) => fetch(request))
};
} catch (error) {
Expand All @@ -51,8 +50,7 @@ export class Server {
handle: () => {
throw error;
},
// @ts-expect-error
handleError: ({ error }) => console.error(error?.stack),
handleError: ({ error }) => console.error(error),
handleFetch: ({ request, fetch }) => fetch(request)
};
} else {
Expand Down

0 comments on commit 789f4c7

Please sign in to comment.