Read Errors and Warnings

Read the code and source location, identify the stage, and decide whether a handler can run.

Read a diagnostic's code and source location to decide what to fix. The stage tells you whether the error occurred before execution or can reach a runtime handler.

The command below uses the native lispex installation from Getting Started.

Read a runtime diagnostic

Save this complete program as pair.lspx.

LISPEX
(car 1)
BASH
lispex run pair.lspx

The command leaves standard output empty, writes the following to standard error, and exits with status 1. It creates no output file.

E310 pair.lspx:1:1 car: expected a pair, got 1
PartWhat it tells you
E310An operation expected a pair.
pair.lspx:1:1Inspect line 1, column 1 of this file.
car: expected a pair, got 1car received the number 1. Check its argument.

To return the first item, replace 1 with a pair, such as '(1 2). The complete expression (car '(1 2)) returns 1.

To handle the failure instead, paste this complete example into the Playground.

LISPEX
(guard (e (else (error-object-message e))) (car 1))

Result

OUTPUT
"car: expected a pair, got 1"

Here guard catches the error object and returns its message as a string. The expression succeeds.

Find the stage and next action

The reader turns source text into values and forms. Normalization checks form structure and rewrites shorthand into core forms. Both happen before execution.

Stage and codesWhat to inspectCan a handler run?
Reader · E100, E140, E150Tokens, parentheses, dotted lists, string and character escapesNo. Repair the source.
Normalization · E110, E130Reserved names and the required parts of each formNo. Repair the binding or form.
Reader or normalization · E120A forbidden extension or formNo. Use syntax supported by the language profile.
Runtime · E300–E340The named operation and the values it receivedRuntime faults can be handled. See the E314 exception below.
Runtime warnings · W330, W331A deprecated procedure nameExecution continues. Use the suggested replacement.
Resource limit · ResourceLimitWork required by the program and its resource profileNo. Resource exhaustion ends the run outside catchable E3xx errors.

E314 needs a stage check. The literal 1e999 fails while being read, even inside guard. Overflow from (* 1e308 1e308) occurs during execution and can be caught.

Runtime diagnostics use fixed message templates and consistent printed values. Most point to the enclosing call. E300 points to the unbound name itself, so (+ 1 missing) points to missing at column 6.

The first uncaught error stops execution. Lispex reports the source diagnostic without a host stack trace. A crash in the calling application must be investigated as an application failure.

Read warnings separately from results

A warning reports a deprecated name while the operation still runs. For example, save this complete program as warning.lspx.

LISPEX
(% 7 3)
BASH
lispex run warning.lspx

Standard output contains the result.

1

Standard error contains the warning.

W330 warning.lspx:1:1 `%` is a deprecated alias of `modulo` — prefer `modulo`

The exit status is 0, and no output file is created. Replace % with modulo to keep the result and remove this warning.

Deprecated nameUse in new codeOperation performed
%modulomodulo
list-firstfirstcar
list-restrestcdr

A genuine deprecated procedure call warns once per source call site, before performing its operation. If your program binds that name to another procedure, calling it does not produce the alias warning.

Keep warnings in occurrence order and separate from standard output and the error diagnostic. If the operation fails, its warning remains recorded. For example, (list-first 1) produces W331 followed by E310.

Look up every code · Handle errors with guard