---
title: "U3008: `if error pass` with a different error kind"
url: https://una-lang.org/en/docs/errors/U3008/
release: v0.4.0
source: https://github.com/una-lang/una/blob/v0.4.0/crates/una-explain/explain/U3008.md
---

# U3008: `if error pass` with a different error kind

An `if error pass` passes a failure whose error kind is not the error kind of the current function.

## Why Una rejects it

`if error pass` propagates a failure unchanged, so the error kind of the expression must equal the error kind of the current function (`spec/06 §3`): a function has at most one error kind (`spec/06 §1`).

A function without `fails` cannot pass a failure at all, except a private one, whose error kind is inferred from its first failure in source order (`spec/04 §5` rule 3, ADR 0099): a pass of another kind is reported here.

## How to fix it

- Convert the failure instead with `if error fail V`, where `V` is a variant of the function's error kind.
- Or declare the kind with `fails`.

## The repair at a glance

```diff
  module demo

  kind StoreError = Timeout | Corrupted

  kind LookupError = Missing | Unavailable

  capability Store
    op find(key: Int) -> Option[Int]
      fails StoreError

  pub lookup(key: Int) -> Option[Int]
    uses @store: Store[find]
    fails LookupError
  =
    @store.find(key)
-     if error pass
+     if error fail Unavailable
```

## Failing example

```una
module demo

kind StoreError = Timeout | Corrupted

kind LookupError = Missing | Unavailable

capability Store
  op find(key: Int) -> Option[Int]
    fails StoreError

pub lookup(key: Int) -> Option[Int]
  uses @store: Store[find]
  fails LookupError
=
  @store.find(key)
    if error pass
```

## Fixed example

```una
module demo

kind StoreError = Timeout | Corrupted

kind LookupError = Missing | Unavailable

capability Store
  op find(key: Int) -> Option[Int]
    fails StoreError

pub lookup(key: Int) -> Option[Int]
  uses @store: Store[find]
  fails LookupError
=
  @store.find(key)
    if error fail Unavailable
```
