diff --git a/packages/svelte/src/internal/client/error-handling.js b/packages/svelte/src/internal/client/error-handling.js index ef311a0540..7d75ac03d9 100644 --- a/packages/svelte/src/internal/client/error-handling.js +++ b/packages/svelte/src/internal/client/error-handling.js @@ -67,7 +67,6 @@ function adjust_error(error, effect) { // if the message was already changed and it's not configurable we can't change it // or it will throw a different error swallowing the original one - if (message_descriptor && !message_descriptor.configurable) return; var indent = is_firefox ? ' ' : '\t'; var component_stack = `\n${indent}in ${effect.fn?.name || ''}`; @@ -78,9 +77,18 @@ function adjust_error(error, effect) { context = context.p; } - define_property(error, 'message', { - value: error.message + `\n${component_stack}\n` - }); + if (!message_descriptor || message_descriptor.configurable) { + define_property(error, 'message', { + value: error.message + `\n${component_stack}\n` + }); + } else { + // eslint-disable-next-line no-console + console.error( + "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" + + error.message + + `\n${component_stack}\n` + ); + } if (error.stack) { // Filter out internal modules