Hyperlinkv0.8.0-beta.28

UndefinedOr

UndefinedOr.getOrThrowconsteffect/UndefinedOr.ts:118
<A>(self: A | undefined): A

Returns the defined value, or throws a default Error when the input is undefined.

When to use

Use when you need to unwrap a value that should already be defined and a generic missing-value Error is acceptable.

Details

Defined inputs are returned unchanged. undefined throws new Error("getOrThrow called on a undefined").

export const getOrThrow: <A>(self: A | undefined) => A = getOrThrowWith(() =>
  new Error("getOrThrow called on a undefined")
)