guard against non-errors

pull/14211/head
Dominic Gannaway 2 years ago
parent 4d8ad249b4
commit 2c8dea6a8c

@ -114,7 +114,7 @@ export function boundary(node, boundary_fn, props) {
);
});
} catch (error) {
handle_error(/** @type {Error} */ (error), boundary, boundary.ctx);
handle_error(error, boundary, boundary.ctx);
}
is_creating_fallback = false;
});

@ -269,11 +269,15 @@ function should_rethrow_error(effect) {
}
/**
* @param {Error} error
* @param {unknown} error
* @param {Effect} effect
* @param {ComponentContext | null} component_context
*/
export function handle_error(error, effect, component_context) {
if (!(error instanceof Error)) {
throw error;
}
if (handled_errors.has(error)) {
if (should_rethrow_error(effect)) {
throw error;
@ -500,7 +504,7 @@ export function update_effect(effect) {
dev_effect_stack.push(effect);
}
} catch (error) {
handle_error(/** @type {Error} */ (error), effect, previous_component_context || effect.ctx);
handle_error(error, effect, previous_component_context || effect.ctx);
} finally {
active_effect = previous_effect;
@ -601,7 +605,7 @@ function flush_queued_effects(effects) {
}
}
} catch (error) {
handle_error(/** @type {Error} */ (error), effect, effect.ctx);
handle_error(error, effect, effect.ctx);
}
}
}
@ -681,7 +685,7 @@ function process_effects(effect, collected_effects) {
update_effect(current_effect);
}
} catch (error) {
handle_error(/** @type {Error} */ (error), current_effect, current_effect.ctx);
handle_error(error, current_effect, current_effect.ctx);
}
}

Loading…
Cancel
Save