(rontolisp) docs
← Macros

error

(error datum args...)

Signals an error, aborting execution unless an enclosing handler-case catches it. The Common Lisp condition designators are supported:

  • (error "control" args...) — the control string must be a literal using the same directives as format (~a, ~s, ~%, ...); the remaining arguments fill them to build the message.
  • (error 'type :initarg value ...) — constructs a condition instance of the named class (built-in or defined by define-condition) and signals it. The message is the class's :report rendering when one is defined, and the Condition (type initargs...) was signalled. shape otherwise; for the simple-* classes a supplied :format-control becomes the message.
  • (error obj) — signals a pre-built condition object (e.g. from make-condition); a value that turns out to be a string at runtime is signaled as a plain message.

The interpreter and JVM backends throw an exception carrying the message and the condition object, so handler-case can dispatch on its type; the WASM backend traps (uncatchable). Like format, error is a macro with no function value, so #'error is unsupported.

Because an uncaught error aborts execution it is shown here statically rather than as a runnable example:

(error "bad value: ~a" x)
(error 'type-error :datum x :expected-type 'integer)