E0003: missing_handler
E0003 missing_handler — a face signal has no on handler.
A compile-time error of soma check, the checker of the Soma programming language (soma explain E0003).
The rule
Every signal declared in a cell's face needs an on handler with the same name in that cell. The face is the contract other cells and HTTP clients rely on, so a declared signal that nothing answers is an error, not a warning. Add the handler with the same parameters as the signal, or remove the signal from the face.
A program that triggers it
wrong.cell
cell Inventory {
face {
signal add_stock(sku: String, qty: Int) -> Int
signal stock_of(sku: String) -> Int
}
memory {
stock: Map<String, Int> [persistent]
}
on add_stock(sku: String, qty: Int) {
let total = (stock.get(sku) ?? 0) + qty
stock.set(sku, total)
return total
}
}What soma check prints:
$ soma check wrong.cell
error: face contract: signal 'stock_of' declared in cell 'Inventory' has no handler
--> wrong.cell:4:9
|
4 | signal stock_of(sku: String) -> Int
| ^
= code: E0003
✗ 1 error(s), 0 warning(s).The fix field of soma check --json: Add a handler to cell 'Inventory':
on stock_of() {
// TODO: implement
return map("status", "ok")
}
The fix
3 lines are added after line 13.
wrong.cell → right.cell
--- wrong.cell
+++ right.cell
@@ -12,3 +12,6 @@
return total
}
+ on stock_of(sku: String) {
+ return stock.get(sku) ?? 0
+ }
}With the fix, soma check accepts the program:
$ soma check right.cell
✓ All checks passed.