MCPcopy
hub / github.com/sveltejs/svelte / handle_error

Function handle_error

packages/svelte/src/internal/client/error-handling.js:15–41  ·  view source on GitHub ↗
(error)

Source from the content-addressed store, hash-verified

13 * @param {unknown} error
14 */
15export function handle_error(error) {
16 var effect = active_effect;
17
18 // for unowned deriveds, don't throw until we read the value
19 if (effect === null) {
20 /** @type {Derived} */ (active_reaction).f |= ERROR_VALUE;
21 return error;
22 }
23
24 if (DEV && error instanceof Error && !adjustments.has(error)) {
25 adjustments.set(error, get_adjustments(error, effect));
26 }
27
28 // if the error occurred while creating this subtree, we let it
29 // bubble up until it hits a boundary that can handle it, unless
30 // it's an $effect in which case it doesn't run immediately
31 if ((effect.f & REACTION_RAN) === 0 && (effect.f & EFFECT) === 0) {
32 if (DEV && !effect.parent && error instanceof Error) {
33 apply_adjustments(error);
34 }
35
36 throw error;
37 }
38
39 // otherwise we bubble up the effect tree ourselves
40 invoke_error_boundary(error, effect);
41}
42
43/**
44 * @param {unknown} error

Callers 1

update_reactionFunction · 0.90

Calls 5

get_adjustmentsFunction · 0.85
apply_adjustmentsFunction · 0.85
invoke_error_boundaryFunction · 0.85
setMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected