Skip to content

Commit 0161aa3

Browse files
committed
fix: print console.error with updated stack
1 parent cd32c37 commit 0161aa3

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/svelte/src/internal/client/error-handling.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ function adjust_error(error, effect) {
6767

6868
// if the message was already changed and it's not configurable we can't change it
6969
// or it will throw a different error swallowing the original one
70-
if (message_descriptor && !message_descriptor.configurable) return;
7170

7271
var indent = is_firefox ? ' ' : '\t';
7372
var component_stack = `\n${indent}in ${effect.fn?.name || '<unknown>'}`;
@@ -78,9 +77,18 @@ function adjust_error(error, effect) {
7877
context = context.p;
7978
}
8079

81-
define_property(error, 'message', {
82-
value: error.message + `\n${component_stack}\n`
83-
});
80+
if (!message_descriptor || message_descriptor.configurable) {
81+
define_property(error, 'message', {
82+
value: error.message + `\n${component_stack}\n`
83+
});
84+
} else {
85+
// eslint-disable-next-line no-console
86+
console.error(
87+
"The following it's not a separate error: we usually modify the error message to show you this information but `message` was non configurable so we print them in a separate log.\n" +
88+
error.message +
89+
`\n${component_stack}\n`
90+
);
91+
}
8492

8593
if (error.stack) {
8694
// Filter out internal modules

0 commit comments

Comments
 (0)