[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Result](https://evolu.dev/docs/api-reference/common/Result) › getOrThrow

```ts
function getOrThrow<T, E>(result: Result<T, E>): T;
```

Defined in: [packages/common/src/Result.ts:476](https://github.com/evoluhq/evolu/blob/037c390af081e9944d616ff298a729515c5c5ab7/packages/common/src/Result.ts#L476)

Gets the value from an [Ok](https://evolu.dev/docs/api-reference/common/Result/interfaces/Ok), or throws for an [Err](https://evolu.dev/docs/api-reference/common/Result/interfaces/Err).

Use this where failure should crash the current flow instead of being handled
locally.

**When to use:**

- Application startup or composition-root setup where errors must stop the
  program immediately. In Evolu apps, the root [Run](https://evolu.dev/docs/api-reference/common/Task/interfaces/Run) reports the defect
  and the platform lifecycle API handles shutdown.
- Module-level constants
- Test setup with values that are expected to be valid

Prefer an explicit `if (!result.ok)` check in ordinary application logic
where the caller can recover, retry, or choose a different flow.

### Example

```ts
import {
  assert,
  assertErr,
  assertEqual,
  assertType,
  err,
  getOrThrow,
  ok,
  trySync,
  type Result,
  type Typed,
} from "@evolu/common";

interface Config {
  readonly port: number;
}

const loadConfig = (): Result<Config, InvalidConfigError> => ok({ port: 3000 });

interface InvalidConfigError extends Typed<"InvalidConfig"> {}

// At app startup, crash if the config is invalid.
const config = getOrThrow(loadConfig());
assertType<Config, typeof config>();
assertEqual(config.port, 3000);

const thrown = trySync(() => getOrThrow(err({ type: "InvalidConfig" })));
assertErr(thrown);
assert(thrown.error instanceof Error, "Expected an Error.");
assertEqual(thrown.error.message, "getOrThrow");
const cause = thrown.error.cause;
assert(
  typeof cause === "object" &&
    cause !== null &&
    "type" in cause &&
    cause.type === "InvalidConfig",
  "Expected InvalidConfig cause.",
);
```

Throws: `Error` with the original error attached as `cause`.