Exit codes and errors

oaknut-basic reports failures the same way every oaknut CLI does: categorised exceptions raised by the library, printed without a traceback and turned into a conventional exit code at the command boundary.

What can go wrong

A tokeniser or de-tokeniser failure is always a problem with the program — malformed source on the way in, or a malformed token stream on the way out — never a bug. Every such error is a DataError, so the process exits with ExitCode.DATA_ERR (65) and prints a one-line explanation to standard error. For example, asking tokenise to auto-number a listing that already has line numbers:

$ printf '10 PRINT\n' | oaknut-basic tokenise --start 10
line 1 is already numbered (line 10) but auto-numbering was requested: '10 PRINT'
Drop --start/--step to tokenise source that already carries line numbers.

The message names the offending line (for source) or byte offset (for a token stream), and where it helps, an actionable note follows — here, that dropping --start / --step tokenises already-numbered source. The exception classes behind these messages, and their attributes, are documented under Error handling.

--debug

A usage mistake — an unknown --encoding, --step 0 — is a Click usage error and exits 2. For everything else, the hidden --debug flag re-raises the categorised error after printing it, so the full Python traceback is visible:

$ oaknut-basic --debug tokenise broken.bas

This is for development; users see the clean message by default.

Summary

Exit code

Meaning

0

Success.

2

Usage error (bad option or value).

65 (DATA_ERR)

Malformed source or token stream.