Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: assign message to error object in handle_error using Object.assign #11675

Merged
merged 10 commits into from
Jun 2, 2024
5 changes: 5 additions & 0 deletions .changeset/shiny-pillows-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"svelte": patch
---

fix: assign message to error object in `handle_error` using `Object.defineProperty`
8 changes: 6 additions & 2 deletions packages/svelte/src/internal/client/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,9 @@ function handle_error(error, effect, component_context) {
}

const indent = /Firefox/.test(navigator.userAgent) ? ' ' : '\t';
error.message += `\n${component_stack.map((name) => `\n${indent}in ${name}`).join('')}\n`;
define_property(error, 'message', {
value: error.message + `\n${component_stack.map((name) => `\n${indent}in ${name}`).join('')}\n`
});

const stack = error.stack;

Expand All @@ -326,7 +328,9 @@ function handle_error(error, effect, component_context) {
}
new_lines.push(line);
}
error.stack = new_lines.join('\n');
define_property(error, 'stack', {
value: error.stack + new_lines.join('\n')
});
}

handled_errors.add(error);
Expand Down
Loading