Home / Function/ prefixError() — astro Function Reference

prefixError() — astro Function Reference

Architecture documentation for the prefixError() function in index.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  3d8168f3_300a_12a4_6a4d_d4c08a494e09["prefixError()"]
  69f93a80_1603_3b35_46fa_5fc7b973b199["index.ts"]
  3d8168f3_300a_12a4_6a4d_d4c08a494e09 -->|defined in| 69f93a80_1603_3b35_46fa_5fc7b973b199
  aae36f52_cdac_44a0_4252_547d557d1d35["createMarkdownProcessor()"]
  aae36f52_cdac_44a0_4252_547d557d1d35 -->|calls| 3d8168f3_300a_12a4_6a4d_d4c08a494e09
  style 3d8168f3_300a_12a4_6a4d_d4c08a494e09 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/markdown/remark/src/index.ts lines 177–198

function prefixError(err: any, prefix: string) {
	// If the error is an object with a `message` property, attempt to prefix the message
	if (err?.message) {
		try {
			err.message = `${prefix}:\n${err.message}`;
			return err;
		} catch {
			// Any errors here are ok, there's fallback code below
		}
	}

	// If that failed, create a new error with the desired message and attempt to keep the stack
	const wrappedError = new Error(`${prefix}${err ? `: ${err}` : ''}`);
	try {
		wrappedError.stack = err.stack;
		wrappedError.cause = err;
	} catch {
		// It's ok if we could not set the stack or cause - the message is the most important part
	}

	return wrappedError;
}

Domain

Subdomains

Frequently Asked Questions

What does prefixError() do?
prefixError() is a function in the astro codebase, defined in packages/markdown/remark/src/index.ts.
Where is prefixError() defined?
prefixError() is defined in packages/markdown/remark/src/index.ts at line 177.
What calls prefixError()?
prefixError() is called by 1 function(s): createMarkdownProcessor.

Analyze Your Own Codebase

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

Try Supermodel Free