Function assertSuccess
- assert
Success<T>(result, expectation?): T Type Parameters
Parameters
result: string | T
A result which might be a string.
expectation: string = 'Expected a successful result, but encountered an error: '
An optional, descriptive prefix for the error message thrown in failure cases. By default,
Expected a successful result, but encountered an error:.
Returns T
Generated using TypeDoc

A utility to handle error results by throwing an
Errorobject.If the provided value is of type
string, the contents of the string are thrown as a newError, otherwise, the value is returned unmodified.This method is useful for eliminating
stringas a possible type from a resulting value, particularly in places where an error is never expected to occur in practice (i.e. no user or runtime input is involved), e.g.: