Skip to content

Utils / Full Stack / tryit

Function: tryit()

ts
function tryit<Args, Return>(func): (...args) => Return extends Promise<any> ? Promise<[Error, undefined] | [undefined, Awaited<Return>]> : [Error, undefined] | [undefined, Return];

A helper to try an async function without forking the control flow. Returns an error first callback like array response as [Error, result]

Type Parameters

Type Parameter

Args extends any[]

Return

Parameters

ParameterType

func

(...args) => Return

Returns

(...args) => Return extends Promise<any> ? Promise<[Error, undefined] | [undefined, Awaited<Return>]> : [Error, undefined] | [undefined, Return]

Version v1.33.1 - Built on 2026-03-28