Skip to content

Commit bfa3b9c

Browse files
rChaozRich-Harris
andauthored
fix: ensure static error page is loaded correctly for custom user errors (#13952)
* fix the bug * changeset * format --------- Co-authored-by: Rich Harris <[email protected]>
1 parent a7b8b28 commit bfa3b9c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

.changeset/fine-pens-attend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
fix: ensure static error page is loaded correctly for custom user errors

packages/kit/src/runtime/server/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ export async function handle_fatal_error(event, state, options, error) {
100100
*/
101101
export async function handle_error_and_jsonify(event, state, options, error) {
102102
if (error instanceof HttpError) {
103-
return error.body;
103+
// @ts-expect-error custom user errors may not have a message field if App.Error is overwritten
104+
return { message: 'Unknown Error', ...error.body };
104105
}
105106

106107
if (__SVELTEKIT_DEV__ && typeof error == 'object') {

0 commit comments

Comments
 (0)