Home / Class/ InternalCompileError Class — svelte Architecture

InternalCompileError Class — svelte Architecture

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

Entity Profile

Dependency Diagram

graph TD
  4c8bae36_901d_e855_4096_25657c0fbc27["InternalCompileError"]
  495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"]
  4c8bae36_901d_e855_4096_25657c0fbc27 -->|defined in| 495501a4_a342_6a4d_ac11_e3e2fee8b218
  c16a81c5_56e2_1ecd_2a57_14f0095ebae7["constructor()"]
  4c8bae36_901d_e855_4096_25657c0fbc27 -->|method| c16a81c5_56e2_1ecd_2a57_14f0095ebae7
  5d96a738_e09b_3281_0901_433d3ea634b6["toString()"]
  4c8bae36_901d_e855_4096_25657c0fbc27 -->|method| 5d96a738_e09b_3281_0901_433d3ea634b6
  1bee6dd1_d84e_0e1b_05bc_412879aaae6a["toJSON()"]
  4c8bae36_901d_e855_4096_25657c0fbc27 -->|method| 1bee6dd1_d84e_0e1b_05bc_412879aaae6a

Relationship Graph

Source Code

packages/svelte/src/compiler/errors.js lines 6–35

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/src/compiler/errors.js.
Where is InternalCompileError defined?
InternalCompileError is defined in packages/svelte/src/compiler/errors.js at line 6.

Analyze Your Own Codebase

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

Try Supermodel Free