Error Handling API

Functions for triggering runtime errors and asserting conditions.

error(message)

Triggers a runtime error with a custom message. Execution halts immediately.

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.

Returns: null if the assertion passes

Truthiness Rules

TypeTruthyFalsy
booltruefalse
nullalways falsy
numbernon-zero0
all othersalways 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