Error Catalogue

Error names are current implementation names, not a stable string-based API; hosts should use the structured error interfaces described in engine-api.md and host-abi.md.

Failure Classes

ClassWhen it occursCan script code recover?
Compile errorParsing, import resolution, declaration checks, or static type checks before execution.No. Fix the source or host configuration.
Runtime panicAn executing operation fails, a trap result is non-null, or a VM resource budget is exhausted.Usually yes, from a deferred function using std.core.recover().
error valueScript or capability code returns std.core.error(...) or another error value.It is ordinary data; check and propagate it explicitly.
Host/engine resultA C, Zig, WASM, or SDK call reports failure.The host reads structured diagnostics and chooses its own recovery.

An unrecovered runtime panic terminates the current script run. A successful recover() stops that panic unwind, but does not resume the expression that failed; control continues according to the recovered function's return path.

Common Compile Errors

ErrorMeaningTypical correction
InvalidChar, BadEscape, UnterminatedString, BadNumberSource text contains an invalid character, literal escape, unfinished string, or malformed number.Correct the literal or source encoding.
UnexpectedToken, ExpectedExpression, ExpectedTypeNameThe source does not match the expected syntax.Check the diagnostic line/column and surrounding delimiter or keyword.
UndefinedVariable, NotDefinedA referenced binding is not visible at that point.Declare it first, import the correct module, or correct its spelling.
UnknownType, UnknownStructType, UnknownTypeNameA type name cannot be resolved.Use a declared/imported type and the required module qualifier.
DuplicateLocal, DuplicateGlobal, DuplicateExport, DuplicateTypeNameA scope or module declares the same name twice.Rename or remove one declaration.
AssignToConstCode assigns to a const or named function binding.Assign through a mutable variable instead.
ImportNotFound, ImportOutsideRoot, ImportCycle, UnsupportedImportModuleA source import cannot be resolved, is outside permitted roots, forms a cycle, or uses an unsupported namespace.Correct the path, add a host-approved module root, remove the cycle, or use cap:/host: as appropriate.
CapabilityNotEnabledThe script imports a capability not enabled by the host.Enable only the intended capability, or remove the import.
ConstraintViolation, WrongTypeArgCountExplicit generic arguments do not meet a constraint or have the wrong count.Correct the explicit arguments. See known-limitations.md for inferred constraint checking.
NonExhaustiveSwitchA variant switch lacks an unguarded arm or default.Cover every variant arm or add default.

Common Runtime Panics

ErrorMeaningAvoidance or handling
TypeError, TypeMismatch, ArityMismatchA dynamic value or call does not satisfy the required type or argument count.Validate dynamic input; use typed declarations and direct function calls where possible.
NotAFunction, UnknownMethod, UnknownFieldCode calls a non-callable value or accesses a missing member.Check the receiver/value shape before dynamic access.
IndexOutOfBounds, RangeErrorAn array/string index, slice, or byte-decoding range is invalid.Validate bounds and input length.
DivisionByZeroInteger division or remainder has a zero divisor.Check the divisor before the operation.
PredicateFailedA named predicate type rejects a value.Validate input before constructing the constrained value.
AssertionFailedassert received false.Use it for test/invariant failures; recover only when the caller has a meaningful policy.
TrapFiredA trap binding received a non-null value.Handle the returned error/value before binding it to trap, or recover in a deferred function.
InstructionBudgetExceededThe configured VM operation budget was used.Set an appropriate limit; simplify or split work. Host callback time needs separate host limits.
OutOfMemory, StackOverflow, CallStackOverflow, DeferStackOverflowA configured heap, VM stack, call-frame, or defer limit was reached.Increase a deliberate host limit or bound script data/recursion.

Capability operations can instead return an ordinary error value, particularly for expected I/O, HTTP, and socket failures. Consult capabilities.md for each operation's return convention; do not treat every non-success as a panic.

Reading Diagnostics

The CLI prints compile diagnostics with a source location and runtime panics with the failure location; a runtime stack trace may follow. The C/native API, WASM API, and TypeScript SDK expose structured diagnostics instead of asking a host to parse CLI text. A host should retain diagnostic text only for the lifetime stated by its API reference, then copy it if it must be preserved.

See also: language.md, cli.md, capabilities.md, engine-api.md, and known-limitations.md.