@ -291,31 +291,21 @@ export function handle_error(error, effect, previous_effect, component_context)
is _throwing _error = true ;
}
if (
! DEV ||
component _context === null ||
! ( error instanceof Error ) ||
handled _errors . has ( error )
) {
propagate _error ( error , effect ) ;
return ;
}
handled _errors . add ( error ) ;
if ( DEV && component _context !== null && error instanceof Error && ! handled _errors . has ( error ) ) {
handled _errors . add ( error ) ;
const component _stack = [ ] ;
const component _stack = [ ] ;
const effect _name = effect . fn ? . name ;
const effect _name = effect . fn ? . name ;
if ( effect _name ) {
component _stack . push ( effect _name ) ;
}
if ( effect _name ) {
component _stack . push ( effect _name ) ;
}
/** @type {ComponentContext | null} */
let current _context = component _context ;
/** @type {ComponentContext | null} */
let current _context = component _context ;
while ( current _context !== null ) {
if ( DEV ) {
while ( current _context !== null ) {
/** @type {string} */
var filename = current _context . function ? . [ FILENAME ] ;
@ -323,35 +313,36 @@ export function handle_error(error, effect, previous_effect, component_context)
const file = filename . split ( '/' ) . pop ( ) ;
component _stack . push ( file ) ;
}
current _context = current _context . p ;
}
current _context = current _context . p ;
}
const indent = is _firefox ? ' ' : '\t' ;
define _property ( error , 'message' , {
value :
error . message + ` \n ${ component _stack . map ( ( name ) => ` \n ${ indent } in ${ name } ` ) . join ( '' ) } \n `
} ) ;
define _property ( error , 'component_stack' , {
value : component _stack
} ) ;
const indent = is _firefox ? ' ' : '\t' ;
define _property ( error , 'message' , {
value : error . message + ` \n ${ component _stack . map ( ( name ) => ` \n ${ indent } in ${ name } ` ) . join ( '' ) } \n `
} ) ;
define _property ( error , 'component_stack' , {
value : component _stack
} ) ;
const stack = error . stack ;
// Filter out internal files from callstack
if ( stack ) {
const lines = stack . split ( '\n' ) ;
const new _lines = [ ] ;
for ( let i = 0 ; i < lines . length ; i ++ ) {
const line = lines [ i ] ;
if ( line . includes ( 'svelte/src/internal' ) ) {
continue ;
const stack = error . stack ;
// Filter out internal files from callstack
if ( stack ) {
const lines = stack . split ( '\n' ) ;
const new _lines = [ ] ;
for ( let i = 0 ; i < lines . length ; i ++ ) {
const line = lines [ i ] ;
if ( line . includes ( 'svelte/src/internal' ) ) {
continue ;
}
new _lines . push ( line ) ;
}
new _lines . push ( line ) ;
define _property ( error , 'stack' , {
value : new _lines . join ( '\n' )
} ) ;
}
define _property ( error , 'stack' , {
value : new _lines . join ( '\n' )
} ) ;
}
propagate _error ( error , effect ) ;