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