Skip to content

The diagnostic is the first line again - #426

Merged
tobert merged 3 commits into
mainfrom
fix/error-presentation-wrapper
Aug 31, 2026
Merged

The diagnostic is the first line again#426
tobert merged 3 commits into
mainfrom
fix/error-presentation-wrapper

Conversation

@tobert

@tobert tobert commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Independent of #421-#425 — this one is off main and touches only the REPL binary and its presentation tests.

An earlier fix moved parse and lexer failures out of the Error: execution failed / Caused by: wrapper so their diagnostic leads. It stopped there, and error_presentation_tests.rs pinned the remaining classes to record that boundary rather than to endorse it.

Everything else that fails during execution was still buried. A validation failure produces the same line:col [code]: message shape a parse error does, and it arrived three lines down:

Error: execution failed

Caused by:
    validation failed:
    error [E012]: bare variable in for loop iterates once …
      → wrap it in $(...) …

The suggested rewrite — the part that tells the reader what to do — was the fifth line of output. Assume the context is truncated and the whole message is gone. It now reads:

validation failed:
error [E012]: bare variable in for loop iterates once …
  → wrap it in $(...) …

execution failed named the phase and nothing else, and as the outermost context anyhow makes it the headline. Removed. Callers print the diagnostic directly rather than letting main re-wrap it with an Error: prefix and a Caused by: split, the same way the parse path already prints.

The boundary that remains is between a generic context and a specific one. Failed to read script: <path> names the file and the action, which the io error under it does not, so it stays and is still pinned. The rule is not "no context", it is "no context that displaces the message with less information than the message".

Untouched and still passing: parse, lexer, command-not-found, a nonzero exit, and a builtin's own error, none of which went through the wrapper. Exit codes are unchanged.

Gates: test --all, clippy (0 warnings), rustdoc, no-default-features, wasi, and insta all green.

tobert and others added 3 commits August 31, 2026 14:10
An earlier fix moved parse and lexer failures out of the
`Error: execution failed` / `Caused by:` wrapper so their diagnostic
leads. It stopped there, and `error_presentation_tests.rs` pinned the
remaining classes to record that boundary rather than to endorse it.

Everything else that fails during execution was still buried. A
validation failure produces the same `line:col [code]: message` shape a
parse error does, and it was arriving three lines down:

    Error: execution failed
    <blank>
    Caused by:
        validation failed:
        error [E012]: bare variable in for loop iterates once …
          → wrap it in $(...) …

The suggested rewrite — the part that tells the reader what to do — was
the fifth line of output. Assume the context is truncated and the whole
message is gone.

`execution failed` named the phase and nothing else, and as the
outermost context anyhow makes it the headline. Removed. The kernel's
own diagnostic leads, and callers print it directly rather than letting
`main` re-wrap it with an `Error:` prefix and a `Caused by:` split, the
same way the parse path already prints.

The boundary that remains is between a GENERIC context and a SPECIFIC
one. `Failed to read script: <path>` names the file and the action,
which the io error under it does not, so it stays and is still pinned.
The rule is not "no context", it is "no context that displaces the
message with less information than the message".

Two pins became assertions about the effect instead of the mechanism.
Untouched and still passing: parse, lexer, command-not-found, a
nonzero exit, and a builtin's own error, none of which went through the
wrapper.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@tobert
tobert merged commit b062520 into main Aug 31, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant