- 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>>
- wrapInTry<Value>(
callback: NoInputsFunction<Value>,
options?: { fallbackValue?: undefined; handleError?: undefined },
): Error | Value Returns Error | Value
- wrapInTry<Value extends Promise<any>, FallbackValue = undefined>(
callback: NoInputsFunction<Value>,
options: {
fallbackValue?: FallbackValue;
handleError: (error: unknown) => FallbackValue;
},
): Promise<Awaited<FallbackValue> | Awaited<Value>> Type Parameters
- Value extends Promise<any>
- FallbackValue = undefined
Returns Promise<Awaited<FallbackValue> | Awaited<Value>>
- wrapInTry<Value, FallbackValue = undefined>(
callback: NoInputsFunction<Value>,
options: {
fallbackValue?: FallbackValue;
handleError: (error: unknown) => FallbackValue;
},
): FallbackValue
| Value Type Parameters
- Value
- FallbackValue = undefined
- wrapInTry<Value extends Promise<any>, FallbackValue = undefined>(
callback: NoInputsFunction<Value>,
options: {
fallbackValue: FallbackValue;
handleError?: (error: unknown) => FallbackValue;
},
): Promise<Awaited<FallbackValue> | Awaited<Value>> Type Parameters
- Value extends Promise<any>
- FallbackValue = undefined
Returns Promise<Awaited<FallbackValue> | Awaited<Value>>
- wrapInTry<Value, FallbackValue = undefined>(
callback: NoInputsFunction<Value>,
options: {
fallbackValue: FallbackValue;
handleError?: (error: unknown) => FallbackValue;
},
): FallbackValue
| Value Type Parameters
- Value
- FallbackValue = undefined
- wrapInTry<Value extends Promise<any>, FallbackValue = undefined>(
callback: NoInputsFunction<Value>,
options?: PartialWithUndefined<
{
fallbackValue: FallbackValue;
handleError: (error: unknown) => FallbackValue;
},
>,
): Promise<FallbackValue | Value | Error> Type Parameters
- Value extends Promise<any>
- FallbackValue = undefined
- wrapInTry<Value, FallbackValue = undefined>(
callback: NoInputsFunction<Value>,
options?: PartialWithUndefined<
{
fallbackValue: FallbackValue;
handleError: (error: unknown) => FallbackValue;
},
>,
): FallbackValue
| Value
| Error 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