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`
9 changes: 7 additions & 2 deletions packages/svelte/src/internal/client/runtime.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DEV } from 'esm-env';
import {
define_property,
get_descriptor,
trueadm marked this conversation as resolved.
Show resolved Hide resolved
Rich-Harris marked this conversation as resolved.
Show resolved Hide resolved
get_descriptors,
get_prototype_of,
is_frozen,
Expand Down Expand Up @@ -311,7 +312,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 +329,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