wrapInTry<Value extends Promise<any>>( callback: NoInputsFunction<Value>, options?: { fallbackValue?: undefined; handleError?: undefined },): Promise<Error | Awaited<Value>> Type Parameters
- Value extends Promise<any>
Returns Promise<Error | Awaited<Value>>
Type Parameters
- Value extends Promise<any>
- FallbackValue = undefined
Returns Promise<Awaited<FallbackValue> | Awaited<Value>>
Type Parameters
- Value
- FallbackValue = undefined
Type Parameters
- Value extends Promise<any>
- FallbackValue = undefined
Returns Promise<Awaited<FallbackValue> | Awaited<Value>>
Type Parameters
- Value
- FallbackValue = undefined
Type Parameters
- Value extends Promise<any>
- FallbackValue = undefined
Type Parameters
- Value
- FallbackValue = undefined
Calls the callback and returns its output. If the callback throws an error, it is handled in the following ways:
handleError
function is provided inoptions
, it is passed the thrown error. The output ofhandleError
is returned bywrapInTry
.fallbackValue
is provided, it is returned bywrapInTry
. The thrown error is ignored.wrapInTry
.Example
Package
@augment-vir/common