formatErrorMessage() — astro Function Reference
Architecture documentation for the formatErrorMessage() function in messages.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD c22b7b22_a441_ec90_5614_6cba0ae12199["formatErrorMessage()"] a89de736_d85a_fc8a_68a9_5d9ea54128d5["messages.ts"] c22b7b22_a441_ec90_5614_6cba0ae12199 -->|defined in| a89de736_d85a_fc8a_68a9_5d9ea54128d5 bb067dbf_824d_9dc3_bda6_399e13135841["formatErrorStackTrace()"] c22b7b22_a441_ec90_5614_6cba0ae12199 -->|calls| bb067dbf_824d_9dc3_bda6_399e13135841 style c22b7b22_a441_ec90_5614_6cba0ae12199 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/core/messages.ts lines 266–310
export function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: boolean): string {
const isOurError = AstroError.is(err) || CompilerError.is(err) || AstroUserError.is(err);
let message = '';
if (isOurError) {
message += red(`[${err.name}]`) + ' ' + renderErrorMarkdown(err.message, 'cli');
} else {
message += err.message;
}
const output = [message];
if (err.hint) {
output.push(` ${bold('Hint:')}`);
output.push(yellow(padMultilineString(renderErrorMarkdown(err.hint, 'cli'), 4)));
}
const docsLink = getDocsForError(err);
if (docsLink) {
output.push(` ${bold('Error reference:')}`);
output.push(` ${cyan(underline(docsLink))}`);
}
if (showFullStacktrace && err.loc) {
output.push(` ${bold('Location:')}`);
output.push(` ${underline(`${err.loc.file}:${err.loc.line ?? 0}:${err.loc.column ?? 0}`)}`);
}
if (err.stack) {
output.push(` ${bold('Stack trace:')}`);
output.push(dim(formatErrorStackTrace(err, showFullStacktrace)));
}
if (err.cause) {
output.push(` ${bold('Caused by:')}`);
let causeMessage = ' ';
if (err.cause instanceof Error) {
causeMessage +=
err.cause.message + '\n' + formatErrorStackTrace(err.cause, showFullStacktrace);
} else {
causeMessage += JSON.stringify(err.cause);
}
output.push(dim(causeMessage));
}
return output.join('\n');
}
Domain
Subdomains
Defined In
Calls
Source
Frequently Asked Questions
What does formatErrorMessage() do?
formatErrorMessage() is a function in the astro codebase, defined in packages/astro/src/core/messages.ts.
Where is formatErrorMessage() defined?
formatErrorMessage() is defined in packages/astro/src/core/messages.ts at line 266.
What does formatErrorMessage() call?
formatErrorMessage() calls 1 function(s): formatErrorStackTrace.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free