Home / Class/ InternalCompileError Class — svelte Architecture

InternalCompileError Class — svelte Architecture

Architecture documentation for the InternalCompileError class in compile-errors.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  f58f5246_8fe8_7bac_5004_bebb4973006b["InternalCompileError"]
  70e3acd4_0094_ad98_da32_055904bb4f55["compile-errors.js"]
  f58f5246_8fe8_7bac_5004_bebb4973006b -->|defined in| 70e3acd4_0094_ad98_da32_055904bb4f55
  09b8c1e9_4b51_2855_0e60_604426913ea9["constructor()"]
  f58f5246_8fe8_7bac_5004_bebb4973006b -->|method| 09b8c1e9_4b51_2855_0e60_604426913ea9
  36d1c888_1520_fcf3_ea6d_dc0daf883da2["toString()"]
  f58f5246_8fe8_7bac_5004_bebb4973006b -->|method| 36d1c888_1520_fcf3_ea6d_dc0daf883da2
  df4e184e_d225_93c4_e638_b60e5d9b5040["toJSON()"]
  f58f5246_8fe8_7bac_5004_bebb4973006b -->|method| df4e184e_d225_93c4_e638_b60e5d9b5040

Relationship Graph

Source Code

packages/svelte/scripts/process-messages/templates/compile-errors.js lines 5–33

class InternalCompileError extends Error {
	message = ''; // ensure this property is enumerable
	#diagnostic;

	/**
	 * @param {string} code
	 * @param {string} message
	 * @param {[number, number] | undefined} position
	 */
	constructor(code, message, position) {
		super(message);
		this.stack = ''; // avoid unnecessary noise; don't set it as a class property or it becomes enumerable

		// We want to extend from Error so that various bundler plugins properly handle it.
		// But we also want to share the same object shape with that of warnings, therefore
		// we create an instance of the shared class an copy over its properties.
		this.#diagnostic = new CompileDiagnostic(code, message, position);
		Object.assign(this, this.#diagnostic);
		this.name = 'CompileError';
	}

	toString() {
		return this.#diagnostic.toString();
	}

	toJSON() {
		return this.#diagnostic.toJSON();
	}
}

Domain

Frequently Asked Questions

What is the InternalCompileError class?
InternalCompileError is a class in the svelte codebase, defined in packages/svelte/scripts/process-messages/templates/compile-errors.js.
Where is InternalCompileError defined?
InternalCompileError is defined in packages/svelte/scripts/process-messages/templates/compile-errors.js at line 5.

Analyze Your Own Codebase

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

Try Supermodel Free