- Preparing search index...
- The search index is not available
@giraugh/tools
- attemptOrElse<TReturn, TError>(fnRes, fnErr): TReturn
-
Type Parameters
-
TReturn
-
TError extends Error
Parameters
-
fnRes: (() => TReturn)
-
- (): TReturn
-
Returns TReturn
-
fnErr: ((err) => TReturn)
-
- (err): TReturn
-
Returns TReturn
Returns TReturn
Attempt to call a function or call a handler if an error occurs.
Returns
the result of fnRes if succesfull or the result of fnErr
Note
the type of the return is always the same regardless of if an error occurs
Example
Example
Example