Home / Function/ callSafely() — astro Function Reference

callSafely() — astro Function Reference

Architecture documentation for the callSafely() function in server.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  6bdb7540_3cf8_62a4_f943_abdf672f35db["callSafely()"]
  12df90c3_b0fe_d858_b821_5011b6067fdb["server.ts"]
  6bdb7540_3cf8_62a4_f943_abdf672f35db -->|defined in| 12df90c3_b0fe_d858_b821_5011b6067fdb
  246d72b2_472d_5097_3c81_0588c08ec2c9["defineAction()"]
  246d72b2_472d_5097_3c81_0588c08ec2c9 -->|calls| 6bdb7540_3cf8_62a4_f943_abdf672f35db
  style 6bdb7540_3cf8_62a4_f943_abdf672f35db fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/actions/runtime/server.ts lines 368–386

async function callSafely<TOutput>(
	handler: () => MaybePromise<TOutput>,
): Promise<SafeResult<z.$ZodType, TOutput>> {
	try {
		const data = await handler();
		return { data, error: undefined };
	} catch (e) {
		if (e instanceof ActionError) {
			return { data: undefined, error: e };
		}
		return {
			data: undefined,
			error: new ActionError({
				message: e instanceof Error ? e.message : 'Unknown error',
				code: 'INTERNAL_SERVER_ERROR',
			}),
		};
	}
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does callSafely() do?
callSafely() is a function in the astro codebase, defined in packages/astro/src/actions/runtime/server.ts.
Where is callSafely() defined?
callSafely() is defined in packages/astro/src/actions/runtime/server.ts at line 368.
What calls callSafely()?
callSafely() is called by 1 function(s): defineAction.

Analyze Your Own Codebase

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

Try Supermodel Free