---
title: "KeyError"
url: https://una-lang.org/en/docs/std/prelude/KeyError/
release: v0.4.0
edition: "0.1 and later"
source: https://github.com/una-lang/una/blob/v0.4.0/docs/std/listing.json
---

# KeyError

A kind of the prelude, in scope in every module. Edition 0.1 and later.

```una
pub kind KeyError = | UnknownKey
```

Why `Keys.hmac` fails: `UnknownKey`, a key name that the key file of the grant does not hold (`spec/14 §3`, `spec/13 §5`).

## Variants

- `UnknownKey`: the key file of the grant holds no key of that name

## Example

`src/shop.una`

```una
module shop

--- Why signing a receipt with a named key failed.
reason(failure: KeyError) -> Text
=
  when failure
    is UnknownKey -> "the key file holds no key of that name"

pub main() -> Unit
  uses @console: Console[print]
=
  @console.print(reason(UnknownKey))
```

`una run .` prints:

```text
the key file holds no key of that name
```

## Specification

- [`spec/14 §3`](https://una-lang.org/en/docs/spec/14-standard-library/#s3)
- [`spec/13 §5`](https://una-lang.org/en/docs/spec/13-diagnostics-and-abi/5-command-line/#s5)

Generated from the standard modules of una v0.4.0 ([`docs/std/listing.json`](https://github.com/una-lang/una/blob/5fec93d88932b333feec25e589355a2cb34c37b5/docs/std/listing.json), which is not part of the specification). The specification governs: [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1).
