Home / Function/ createSafeError() — astro Function Reference

createSafeError() — astro Function Reference

Architecture documentation for the createSafeError() function in utils.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  c1dd0964_41cb_7ea4_4e33_356eb3f5c318["createSafeError()"]
  a37e7fee_e130_2a00_6f99_81cf3cf65c83["utils.ts"]
  c1dd0964_41cb_7ea4_4e33_356eb3f5c318 -->|defined in| a37e7fee_e130_2a00_6f99_81cf3cf65c83
  style c1dd0964_41cb_7ea4_4e33_356eb3f5c318 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/errors/utils.ts lines 106–117

export function createSafeError(err: any): Error {
	if (err instanceof Error || (err?.name && err.message)) {
		return err;
	} else {
		const error = new Error(JSON.stringify(err));

		(error as SSRError).hint =
			`To get as much information as possible from your errors, make sure to throw Error objects instead of \`${typeof err}\`. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error for more information.`;

		return error;
	}
}

Domain

Subdomains

Frequently Asked Questions

What does createSafeError() do?
createSafeError() is a function in the astro codebase, defined in packages/astro/src/core/errors/utils.ts.
Where is createSafeError() defined?
createSafeError() is defined in packages/astro/src/core/errors/utils.ts at line 106.

Analyze Your Own Codebase

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

Try Supermodel Free