Saying what can fail: fails
A function or action lists the failures it can end with after fails, in
its signature:
function check_title(title: TodoTitle) fails TitleBlank -> TodoTitle { if (title == "") { reject TitleBlank } return title}action rename(todo_id: Todo.id, title: TodoTitle) fails TodoNotFound, TitleBlank -> TodoView { var checked: TodoTitle = attempt check_title(title) var todo: Todo = attempt Todo.get(todo_id) ...}
fails comes before the result type's ->
(Signatures and settings). It
lists exactly the failures that can leave the callable: everything a
reject or an attempt in its body can produce, less what a match
handles. Functions and actions follow the same rule.
- A failure that can leave but isn't listed is
failure.undeclared_propagation. - One that is listed but can never happen is
failure.stale_declaration. - One listed twice is
failure.duplicate_declaration.
Faults are never listed.
Markdown for agents: /docs/saying-what-can-fail-fails.md.Built from Jadpo main at a707efb.