Hyperlinkv0.8.0-beta.28

Result

Result.getOrThrowconsteffect/Result.ts:1257
<A, E>(self: Result<A, E>): A

Extracts the success value or throws the raw failure value E.

When to use

Use when unchecked boundaries should turn failures into thrown exceptions.

Details

  • Success<A> returns A
  • Failure<E> throws E directly
  • Use getOrThrowWith for a custom error object

Example (Unwrapping or throwing)

import { Result } from "effect"

console.log(Result.getOrThrow(Result.succeed(1)))
// Output: 1

// This would throw the string "error":
// Result.getOrThrow(Result.fail("error"))
Source effect/Result.ts:12571 lines
export const getOrThrow: <A, E>(self: Result<A, E>) => A = getOrThrowWith(identity)
Referenced by 2 symbols