[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:471](https://github.com/evoluhq/evolu/blob/dd96d79f1dbe9a49fa12ce8e0aa7d3d0177795ca/packages/common/src/Result.ts#L471)

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 {
  assertEqual,
  assertErr,
  assertInstanceOf,
  assertSame,
  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<typeof config, Config>();
assertEqual(config.port, 3000);

const invalidConfigError: InvalidConfigError = { type: "InvalidConfig" };
const thrown = trySync(() => getOrThrow(err(invalidConfigError)));
assertErr(thrown);
assertInstanceOf(thrown.error, Error);
assertEqual(thrown.error.message, "getOrThrow");
assertSame(thrown.error.cause, invalidConfigError);
```

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