Skip to content

Commit 2c8dea6

Browse files
committed
guard against non-errors
1 parent 4d8ad24 commit 2c8dea6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

packages/svelte/src/internal/client/dom/blocks/boundary.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export function boundary(node, boundary_fn, props) {
114114
);
115115
});
116116
} catch (error) {
117-
handle_error(/** @type {Error} */ (error), boundary, boundary.ctx);
117+
handle_error(error, boundary, boundary.ctx);
118118
}
119119
is_creating_fallback = false;
120120
});

packages/svelte/src/internal/client/runtime.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,15 @@ function should_rethrow_error(effect) {
269269
}
270270

271271
/**
272-
* @param {Error} error
272+
* @param {unknown} error
273273
* @param {Effect} effect
274274
* @param {ComponentContext | null} component_context
275275
*/
276276
export function handle_error(error, effect, component_context) {
277+
if (!(error instanceof Error)) {
278+
throw error;
279+
}
280+
277281
if (handled_errors.has(error)) {
278282
if (should_rethrow_error(effect)) {
279283
throw error;
@@ -500,7 +504,7 @@ export function update_effect(effect) {
500504
dev_effect_stack.push(effect);
501505
}
502506
} catch (error) {
503-
handle_error(/** @type {Error} */ (error), effect, previous_component_context || effect.ctx);
507+
handle_error(error, effect, previous_component_context || effect.ctx);
504508
} finally {
505509
active_effect = previous_effect;
506510

@@ -601,7 +605,7 @@ function flush_queued_effects(effects) {
601605
}
602606
}
603607
} catch (error) {
604-
handle_error(/** @type {Error} */ (error), effect, effect.ctx);
608+
handle_error(error, effect, effect.ctx);
605609
}
606610
}
607611
}
@@ -681,7 +685,7 @@ function process_effects(effect, collected_effects) {
681685
update_effect(current_effect);
682686
}
683687
} catch (error) {
684-
handle_error(/** @type {Error} */ (error), current_effect, current_effect.ctx);
688+
handle_error(error, current_effect, current_effect.ctx);
685689
}
686690
}
687691

0 commit comments

Comments
 (0)