This page is the canonical user-facing diagnostics contract for Sona 0.15.1.
Documentation truth rule: if this page and runtime behavior disagree, runtime behavior wins and this page must be corrected before release.
Sona command-line diagnostics use this compact shape:
SonaXError: short summary
at path/to/file.sona:line:column: source line
hint: one actionable next step
Rules:
- Errors print to stderr.
- Error exits are nonzero.
- Stack traces are hidden by default.
- Hints are one line, actionable, and specific.
- Normal runs must not print parser, interpreter, or debug setup noise.
sona run supports three error output modes:
| Mode | Command | Behavior |
|---|---|---|
| Explain | sona run file.sona --errors=explain |
Default compact diagnostic only. |
| Trace | sona run file.sona --errors=trace |
Python traceback for runtime debugging. |
| Both | sona run file.sona --errors=both |
Compact diagnostic first, traceback second. |
Use explain for normal development and teaching. Use trace or both when
debugging Sona internals or filing a runtime bug.
Command:
sona run missing.sonaShape:
SonaFileError: file not found: missing.sona
hint: check the path and run the command again.
Fix:
sona run hello.sonaBroken code:
print("missing close);
Shape:
SonaSyntaxError: ...
at syntax.sona:1: print("missing close);
hint: check punctuation, quotes, and balanced brackets.
Fix:
print("missing close");
Broken code:
print(total);
Shape:
SonaNameError: ...
hint: declare it with let before using it.
Fix:
let total = 5;
print(total);
Broken code:
import mathh;
Shape:
SonaImportError: module 'mathh' not found
hint: did you mean 'math'?
Fix:
import math;
print(math.add(2, 3));
If no close match exists, Sona prints:
hint: check the module name and that it is available.
Broken code:
let total = 1 + [2];
Shape:
SonaTypeError: ...
hint: check the value and arguments used in this call.
Fix by combining compatible values:
let total = 1 + 2;
print(total);
Runtime errors that do not fit a narrower category use:
SonaRuntimeError: short summary
Use --errors=both when the compact message is not enough to identify the
underlying runtime path.
Invalid CLI usage uses SonaUsageError.
Examples:
sona
sona run
sona --unknownShape:
SonaUsageError: ...
hint: use 'sona --help' for available commands.
- Read the first
SonaXError:line. - Follow the
hint:line. - Check the
at ...line for file and source context. - Rerun with
--errors=bothonly if you need the traceback.