throwAndExit() — astro Function Reference
Architecture documentation for the throwAndExit() function in throw-and-exit.ts from the astro codebase.
Entity Profile
Dependency Diagram
graph TD 5836b0a2_0b9f_fe96_2b51_f7723d838994["throwAndExit()"] d6caebb2_f869_cb76_46b3_43d67745224c["throw-and-exit.ts"] 5836b0a2_0b9f_fe96_2b51_f7723d838994 -->|defined in| d6caebb2_f869_cb76_46b3_43d67745224c style 5836b0a2_0b9f_fe96_2b51_f7723d838994 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/astro/src/cli/throw-and-exit.ts lines 9–34
export async function throwAndExit(cmd: string, err: unknown) {
// Suppress ZodErrors from AstroConfig as the pre-logged error is sufficient
if (isAstroConfigZodError(err)) {
process.exit(1);
}
let telemetryPromise: Promise<any>;
let errorMessage: string;
function exitWithErrorMessage() {
console.error(errorMessage);
process.exit(1);
}
const errorWithMetadata = collectErrorMetadata(createSafeError(err));
telemetryPromise = telemetry.record(eventError({ cmd, err: errorWithMetadata, isFatal: true }));
errorMessage = formatErrorMessage(errorWithMetadata, true);
// Timeout the error reporter (very short) because the user is waiting.
// NOTE(fks): It is better that we miss some events vs. holding too long.
// TODO(fks): Investigate using an AbortController once we drop Node v14.
setTimeout(exitWithErrorMessage, 400);
// Wait for the telemetry event to send, then exit. Ignore any error.
await telemetryPromise
.catch((err2) => debug('telemetry', `record() error: ${err2.message}`))
.then(exitWithErrorMessage);
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does throwAndExit() do?
throwAndExit() is a function in the astro codebase, defined in packages/astro/src/cli/throw-and-exit.ts.
Where is throwAndExit() defined?
throwAndExit() is defined in packages/astro/src/cli/throw-and-exit.ts at line 9.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free