Skip to content

fix: include the io source when displaying Error::Io - #28

Merged
encounter merged 1 commit into
encounter:mainfrom
rom-weaver:upstream-io-error-source
Sep 16, 2026
Merged

encounter merged 1 commit into
encounter:mainfrom
rom-weaver:upstream-io-error-source

Conversation

@brandonocasey

@brandonocasey brandonocasey commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

When something breaks deep inside nod you tend to get a message like:

Failed to process block 1

That tells you where it broke but not why. The why is already sitting in the error, it just never gets printed.

Error::Io holds two things: a bit of context, and the real io::Error underneath. The Display impl is "{0}", so it prints the context and throws the useful half away. You only get it back if whatever catches the error walks the source chain itself, and most callers just print the error.

Printing both gives you:

Failed to process block 1: Reading block for sector 0: Bad file descriptor (os error 8)

which actually tells you what happened.

I ran into this chasing a threading bug in a project that embeds nod. "Failed to process block 1" was the only thing I had, and it was a dead end. I patched this one line locally to see what was underneath, and the cause was obvious immediately.

It's only the format string. No types change, no behaviour changes. The nesting reads fine because io_context already wraps an Error::Io, so each layer of context just adds one more piece to the message.

cargo check --workspace is clean.

Error::Io holds a context string plus the io::Error underneath it as a
#[source], but Display was "{0}", so it printed the context and dropped
the cause. Callers that just print the error never see what actually
went wrong.

Before:

    Failed to process block 1

After:

    Failed to process block 1: Reading block for sector 0: Bad file descriptor (os error 8)

Only the format string changes.
@brandonocasey
brandonocasey force-pushed the upstream-io-error-source branch from 9360f99 to 35d4734 Compare July 25, 2026 19:16
@encounter
encounter merged commit 5b8a5e2 into encounter:main Sep 16, 2026
44 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.

2 participants