@@ -255,6 +255,18 @@ function handle_error(error, effect, component_context) {
255
255
256
256
const component_stack = [ ] ;
257
257
258
+ const effect_name = effect . fn . name ;
259
+
260
+ if ( effect_name ) {
261
+ // If we have an effect name, it means it happened in the template, $effect or $effect.pre.
262
+ Object . defineProperty ( error , '__skip_hydration_retry' , {
263
+ value : true ,
264
+ enumerable : false
265
+ } ) ;
266
+
267
+ component_stack . push ( effect_name ) ;
268
+ }
269
+
258
270
/** @type {import("#client").ComponentContext | null } */
259
271
let current_context = component_context ;
260
272
@@ -268,27 +280,9 @@ function handle_error(error, effect, component_context) {
268
280
269
281
current_context = current_context . p ;
270
282
}
271
- const effect_name = effect . fn . name ;
272
-
273
- if ( effect_name ) {
274
- // If we have an effect name, it means it happened in the template, $effect or $effect.pre.
275
- Object . defineProperty ( error , '__skip_hydration_retry' , {
276
- value : true ,
277
- enumerable : false
278
- } ) ;
279
- }
280
-
281
- let component_stack_string =
282
- `Svelte caught an error thrown by ${ component_stack [ 0 ] } ${ effect_name ? ` during a${ effect_name . startsWith ( '$' ) ? 'n' : '' } ${ effect_name } ` : '' } .` +
283
- ` You should fix this error in your code.\n\nError: ${ error . message } \n\nThe component stack when this error occured:\n` ;
284
-
285
- for ( const name of component_stack ) {
286
- component_stack_string += `\t${ name } \n` ;
287
- }
288
-
289
- component_stack_string += '\nThe error is located at:\n' ;
290
283
291
- error . message = component_stack_string ;
284
+ const indent = / F i r e f o x / . test ( navigator . userAgent ) ? ' ' : '\t' ;
285
+ error . message += `\n${ component_stack . map ( ( name ) => `\n${ indent } in ${ name } ` ) . join ( '' ) } \n` ;
292
286
293
287
const stack = error . stack ;
294
288
0 commit comments