Home / Function/ handle_error() — svelte Function Reference

handle_error() — svelte Function Reference

Architecture documentation for the handle_error() function in error-handling.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  6c1ccbf4_9a62_285e_f0c7_95d2b223818c["handle_error()"]
  a502a1d2_db34_608a_1001_5401b198ec66["error-handling.js"]
  6c1ccbf4_9a62_285e_f0c7_95d2b223818c -->|defined in| a502a1d2_db34_608a_1001_5401b198ec66
  db550759_ee3b_160c_8afa_d1aa9fae478c["fn()"]
  db550759_ee3b_160c_8afa_d1aa9fae478c -->|calls| 6c1ccbf4_9a62_285e_f0c7_95d2b223818c
  9e5743e3_8b9e_0ad6_5140_1a5ffaca62cd["update_reaction()"]
  9e5743e3_8b9e_0ad6_5140_1a5ffaca62cd -->|calls| 6c1ccbf4_9a62_285e_f0c7_95d2b223818c
  f3a3e160_5beb_7c11_cb81_2668cf6cc2cd["get_adjustments()"]
  6c1ccbf4_9a62_285e_f0c7_95d2b223818c -->|calls| f3a3e160_5beb_7c11_cb81_2668cf6cc2cd
  948bb212_9630_4e89_1013_f72727291511["apply_adjustments()"]
  6c1ccbf4_9a62_285e_f0c7_95d2b223818c -->|calls| 948bb212_9630_4e89_1013_f72727291511
  623c7d5f_8856_1cec_42aa_d58e310da5d1["invoke_error_boundary()"]
  6c1ccbf4_9a62_285e_f0c7_95d2b223818c -->|calls| 623c7d5f_8856_1cec_42aa_d58e310da5d1
  style 6c1ccbf4_9a62_285e_f0c7_95d2b223818c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/internal/client/error-handling.js lines 15–44

export function handle_error(error) {
	var effect = active_effect;

	// for unowned deriveds, don't throw until we read the value
	if (effect === null) {
		/** @type {Derived} */ (active_reaction).f |= ERROR_VALUE;
		return error;
	}

	if (DEV && error instanceof Error && !adjustments.has(error)) {
		adjustments.set(error, get_adjustments(error, effect));
	}

	if ((effect.f & EFFECT_RAN) === 0) {
		// if the error occurred while creating this subtree, we let it
		// bubble up until it hits a boundary that can handle it
		if ((effect.f & BOUNDARY_EFFECT) === 0) {
			if (DEV && !effect.parent && error instanceof Error) {
				apply_adjustments(error);
			}

			throw error;
		}

		/** @type {Boundary} */ (effect.b).error(error);
	} else {
		// otherwise we bubble up the effect tree ourselves
		invoke_error_boundary(error, effect);
	}
}

Domain

Subdomains

Frequently Asked Questions

What does handle_error() do?
handle_error() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/error-handling.js.
Where is handle_error() defined?
handle_error() is defined in packages/svelte/src/internal/client/error-handling.js at line 15.
What does handle_error() call?
handle_error() calls 3 function(s): apply_adjustments, get_adjustments, invoke_error_boundary.
What calls handle_error()?
handle_error() is called by 2 function(s): fn, update_reaction.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free