Package: effect
Module: Option
Extracts the value from a Some, or throws a default Error for None.
When to use
Use when you need quick fail-fast unwrapping of an Option and a generic
error is acceptable.
Details
Some → returns the inner valueNone → throws new Error("getOrThrow called on a None")Example (Throwing a default error)
import { Option } from "effect"
console.log(Option.getOrThrow(Option.some(1)))
// Output: 1
Option.getOrThrow(Option.none())
// throws Error: getOrThrow called on a None
See
getOrThrowWith for a custom errorgetOrElse for a non-throwing alternativeSignature
declare const getOrThrow: <A>(self: Option<A>) => A
Since v2.0.0