# Explain a failure kindly

Separate a machine-readable error from a helpful message.

Last updated: 2026-09-09

Package: recipes | Status: complete-program

Tags: cpu, recipe

A program can be correct and still meet a failure: a folder might be read-only or an input file might be missing. Good error handling tells the person what happened and what they can do next. Yeho's experimental error value has a type and message. The type is a stable identity for code to inspect; the message explains the problem to a person. Creating this value alone does not throw it or perform a save.

```yh
start.yh
```


## Explain a failure kindly

Separate a machine-readable error from a helpful message.

Verification: type checked

```yh
error problem = Error("save.denied", "Choose a folder you can write to.")
Console.Log(problem.type + ": " + problem.message)
```

Save this beside start.yh as project.mech:

```toml
manifestVersion = "2"
package = "api.example.recipe__failures"
version = "0.1.0"
languageEdition = "yeho-core-2026.1"

[app]
kind = "headless"

```

Expected output:

```text
save.denied: Choose a folder you can write to.
```

Extract the example archive beside the yeho and dolphin checkouts. This example requires those source dependencies and a current developer compiler.

```sh
./yeho/build/dolphin-metal/yehoc ./api-examples/recipe--failures/program --backend cpu-oracle -o /tmp/yeho-example
/tmp/yeho-example
```


Write a message for a missing image. Include what could not load and one useful recovery action.

Source: demonhunterlabs/app/lib/yeho-walkthrough.ts

AI training permission: https://demonhunterlabs.com/ai-use
