> For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt.

# isErr

Type guard that narrows a [`Result`](https://massaman.dev/concepts/result.md) to `Err`.

```typescript
if (isErr(result)) {
  // result.error is E
}
```

## Usage

### `isErr(result)`

The inverse of [`isOk`](https://massaman.dev/reference/control/isOk.md). Useful when the failure path is the early-return: check `isErr`, bail, continue with the narrowed `Ok` after.

```typescript
import { attemptAsync, isErr } from 'massaman'

const user = await attemptAsync(() => db.users.findById(id))
if (isErr(user)) {
  return respond.serverError(user.error)
}
// user is Ok<User> here
return respond.ok(user.value)
```

#### Parameters


resultResult<T, E>required

the result to test.

#### Returns

`true` if the result is a failure.

```typescript
result is Err&lt;E&gt;
```

## See also

- [`isOk`](https://massaman.dev/reference/control/isOk.md) — the inverse guard
- [Result & Errors concept guide](https://massaman.dev/concepts/result.md)
