Error Handling API
Functions for triggering runtime errors and asserting conditions.
error(message)
Triggers a runtime error with a custom message. Execution halts immediately.
message(string) — the error message to display
Returns: never returns (execution halts)
error("Something went wrong") // Runtime error: Something went wrong error("File not found: config.zym") // Runtime error: File not found: config.zym
assert(condition, message)
Asserts that a condition is truthy. If the condition is falsy, triggers a runtime error with the provided message.
condition(any) — the value to test for truthinessmessage(string) — the error message if assertion fails
Returns: null if the assertion passes
Truthiness Rules
| Type | Truthy | Falsy |
|---|---|---|
bool | true | false |
null | — | always falsy |
number | non-zero | 0 |
| all others | always truthy | — |
assert(x > 0, "x must be positive") assert(name != null, "name is required") // Passes silently: assert(true, "ok") assert(42, "ok") assert("hello", "ok") // Fails: assert(false, "this fails") // Runtime error: this fails assert(null, "this fails") // Runtime error: this fails assert(0, "this fails") // Runtime error: this fails