---
title: "Recipe: tell the person something failed"
description: "A failure the person must acknowledge is the platform's one-button alert: a dialog role=\"alertdialog\" with its text and one closing button."
modificationDate: "2026-11-12"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: tell the person something failed

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/error-alert: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

A failure the person must acknowledge is the platform's one-button alert: a `dialog
role="alertdialog"` with its text and one closing `button`. State holds the message; the
action that learns of the failure sets it and calls `showModal(id)`.

```prompt Tell the person when something fails
Make the Exact app in this folder tell the person in an alert when a save or another action fails. Use https://github.com/expo/exact/blob/main/docs/recipes/error-alert.md as the source for each step. The Exact checkout has the same page at docs/recipes/error-alert.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me.
2. If I did not say which failure, list the mutations in app.contract and ask me which ones the person must acknowledge.
3. Make the source in app.ts answer `{ ok, error }` for each refusal, with a short message that says why.
4. In app.contract, add a `problem` state and give the mutation `then` an action that sets `problem` and calls `showModal` when the answer is a refusal. Draw a `dialog role="alertdialog"` with a short `aria-label` as its title, the problem as its text, and one OK button with `commandfor` and `command="close"` and no `press`.
5. `then` does not run when a request brings no answer: show `failed(<mutation>)` on the screen for that case. Keep long text out of the alert; it belongs in a sheet.
6. Add a test in app.test.contract that causes the refusal, runs `clock data` and `clock settle`, expects the message, taps OK, and expects the person's input to stay.
7. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 8) and report it; do not keep trying.
8. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
9. Tell me which failures show an alert and their text, what the tests and verify reported, and the launch command for each target platform.
```

```contract
shape Reply
  ok: bool
  error: string

component App
  state draft = ""
  state problem = ""
  mutation saved as shape Reply then afterSave
  derive refusal = match saved { case some(r) => r.ok ? "" : r.error, case none => "" }
  action edit(v: string)
    draft = v
  action save
    send saved = saveNote(draft)
  action afterSave
    if refusal != ""
      problem = refusal
      showModal("failed")
  view
    column padding=16 gap=8
      input value=draft input=edit aria-label="Note" testId="draft"
      button press=save disabled=pending(saved) buttonStyle="filled" testId="save"
        text "Save"
      dialog id="failed" role="alertdialog" aria-label="Couldn’t Save Note"
        text problem testId="problem"
        button commandfor="failed" command="close" testId="failed-ok"
          text "OK"
```

```ts
import type { Answer, Sources } from './app.contract.d.ts';

export const grants = '';

const sources: Sources = {
  saveNote: ([text]) => text.length > 40
    ? { ok: false, error: 'A note is at most 40 characters.' }
    : { ok: true, error: '' },
};
export const answer: Answer = (source, args, store, storage, native) => sources[source](args, store, storage, native);
```

```contract-test
test "a refused save says why, and OK keeps the draft"
  type "draft" "A note far too long to be saved in one go"
  tap "save"
  clock data
  clock settle
  expect text "problem" == "A note is at most 40 characters."
  tap "failed-ok"
  clock settle
  expect text "draft" == "A note far too long to be saved in one go"
```

- The `aria-label` is the alert's title and the `text` its message. iOS shows
  `UIAlertController`, macOS `NSAlert` (Return presses OK), the web its modal `dialog`.
- Keep the title short and the message brief, as Apple's
  [HIG](https://developer.apple.com/design/human-interface-guidelines/alerts) asks: an alert
  is not for long text, which belongs in a sheet. A long one still scrolls in its own box
  where the host draws the alert (the web, Linux), its title and OK in view.
- The button has no `press`: it only closes. Give it one and the dialog is a
  confirmation, which needs its Cancel ([confirm](https://exact.expo.dev/learn/contract-for-agents/time-motion-graphics-and-platform-facts.md#a-confirmation)).
- On iOS, an error that arrives while another confirmation is open waits until that
  confirmation closes. Waiting alerts appear in request order; `close(id)` cancels a
  waiting alert, and a removed dialog never presents later. Waiting alerts appear before
  dialogs opened by the preceding alert’s chosen action.
- `then` does not run for a request that brought no answer: show `failed(saved)` in place
  ([fetch with loading, error and retry](https://exact.expo.dev/recipes/fetch-loading-error.md)).
