Home / Docs / Standard library / Prelude

KeyError

Release v0.4.0Edition 0.1 and later

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

Example

src/shop.unauna
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

Generated from the standard modules of una v0.4.0 (docs/std/listing.json, which is not part of the specification). The specification governs: spec/14 §1.