---
title: "7.11 Recap and reference"
url: https://una-lang.org/en/learn/failure/recap-and-reference/
release: v0.4.0
edition: "0.2"
---

# 7.11 Recap and reference

## 7.11.1 For agents

:::agents
Every diagnostic of [Common mistakes](https://una-lang.org/en/learn/failure/common-mistakes/#s7-9) is available as JSON with `una --json check .`. For [Forgetting the clause](https://una-lang.org/en/learn/failure/common-mistakes/#forgetting-the-clause-u3007):

```json include="mistakes/1/expected/commands/json.txt#L2"
{"schema":"una.diagnostics/1","diagnostics":[{"schema":"una.diagnostic/1","code":"U3007","severity":"error","domain":"authority","message":"`parse_order` can fail with `OrderError`; handle the failure with an `if error` clause, or wrap the call in `attempt`","primary":{"file":"src/orders.una","start":{"line":58,"col":15},"end":{"line":58,"col":32}},"related":[],"repairs":[],"explain":"una explain U3007"}],"fixable":0}
```

`repairs` is empty because the right clause depends on intent, which only the author knows. U0101 for a clause on the same line ([the clause on the same line](https://una-lang.org/en/learn/failure/common-mistakes/#the-clause-on-the-same-line-u0101)) and U3009 for a missing `fails` ([a public function that fails without saying so](https://una-lang.org/en/learn/failure/common-mistakes/#a-public-function-that-fails-without-saying-so-u3009)) carry exact edits, which `una fix .` applies. The compact rule: *a call that can fail is the whole expression of its statement, followed by `if error …` and then `if none …` on their own lines, or is wrapped in `attempt`, which gives a `Result`.*
:::

## 7.11.2 Recap

:::recap
- A value that may be missing is an `Option[T]`, `Some(value)` or `None`: take it apart with `when`, or use `or_else`.
- A failure is a value of a sum kind you declare, whose variants carry what a person needs.
- A header declares at most one error kind with `fails`, or `fails of p`. A `pub` function must declare it; a private one may leave it to inference.
- A call that can fail is the whole expression of its statement, and its handling clauses follow on their own lines: `if error` first, then `if none`.
- `use` carries on, `pass` hands on the same kind, `fail V(cause: error)` translates.
- `attempt` keeps the outcome of one call as a `Result`, `Ok` or `Err`.
- `checked` is a budgeted run-time test for facts no proof can establish. Use it once, where data enters; prefer a guard when you can.
- Give every failure path an example.
:::

## 7.11.3 Reference

:::reference
- Construct pages: [`fails`](https://una-lang.org/en/docs/language/errors/fails/), [`fail`](https://una-lang.org/en/docs/language/errors/fail/), [`if error` and `if none`](https://una-lang.org/en/docs/language/errors/if-error/), [`attempt`](https://una-lang.org/en/docs/language/errors/attempt/), [`checked` and the escape budget](https://una-lang.org/en/docs/language/errors/checked/), [`predicate`](https://una-lang.org/en/docs/language/types/predicate/), [`example`](https://una-lang.org/en/docs/language/examples/example/)
- Prelude: [`Option`, `Result`, `or_else`, `is_some`, `is_ok`, `to_int`, `find`, `parse_int`, `ParseError`](https://una-lang.org/en/docs/std/)
- Configuration: [`[escape_budget] checked_per_module`](https://una-lang.org/en/docs/configure/escape-budget/checked-per-module/)
- Diagnostics: [U0101](https://una-lang.org/en/docs/errors/U0101/), [U0102](https://una-lang.org/en/docs/errors/U0102/), [U1001](https://una-lang.org/en/docs/errors/U1001/), [U2001](https://una-lang.org/en/docs/errors/U2001/), [U2007](https://una-lang.org/en/docs/errors/U2007/), [U2016](https://una-lang.org/en/docs/errors/U2016/) (an opaque predicate called outside `checked`), [U3007](https://una-lang.org/en/docs/errors/U3007/), [U3008](https://una-lang.org/en/docs/errors/U3008/), [U3009](https://una-lang.org/en/docs/errors/U3009/), [U3013](https://una-lang.org/en/docs/errors/U3013/), [U5001](https://una-lang.org/en/docs/errors/U5001/) (a refinement the verifier refutes), [U7003](https://una-lang.org/en/docs/errors/U7003/) (`checked` beyond the escape budget), [U3025](https://una-lang.org/en/docs/errors/U3025/) and [U3026](https://una-lang.org/en/docs/errors/U3026/) (edition `0.3`: a clause or `attempt` on a call that cannot fail), and the stops at run time: [U6001](https://una-lang.org/en/docs/errors/U6001/) (`main` failed with its declared kind), [U6003](https://una-lang.org/en/docs/errors/U6003/) (call depth or memory), [U6004](https://una-lang.org/en/docs/errors/U6004/) (an HTTP header value with a control character), [U6005](https://una-lang.org/en/docs/errors/U6005/) (host text that is not valid UTF-8) and [U8001](https://una-lang.org/en/docs/errors/U8001/) (an internal error of una)
- Specification: [errors](https://una-lang.org/en/docs/spec/06-errors/), [types](https://una-lang.org/en/docs/spec/03-types/), [the standard library](https://una-lang.org/en/docs/spec/14-standard-library/), [text](https://una-lang.org/en/docs/spec/22-text/)
:::
