Skip to content

Report a usable error when pty_spawn fails - #9

Open
JohnCampionJr wants to merge 1 commit into
tomlm:mainfrom
JohnCampionJr:fix/spawn-error-message
Open

Report a usable error when pty_spawn fails#9
JohnCampionJr wants to merge 1 commit into
tomlm:mainfrom
JohnCampionJr:fix/spawn-error-message

Conversation

@JohnCampionJr

Copy link
Copy Markdown

A failed spawn currently reports:

pty_spawn failed with error -6: errno -6

which names nothing, and is actively misleading — errno is never negative, so that number isn't an errno at all.

Two changes

The message carries all three result-struct fields plus the app being spawned, so a failure says what was attempted and what came back rather than one unexplained number.

GetErrorMessage stops guessing. The curated switch covered four errno values and rendered everything else as the bare number — so the failures it could name were the ordinary ones, and the interesting ones fell through. Win32Exception maps an errno through strerror on Unix, which names all of them.

A non-positive value is called out as not being an errno rather than translated. That distinction is the useful part: seeing one means the result struct didn't carry what the caller expected, which is a different problem from whatever errno would have described. Getting -6 and having strerror answer "Undefined error: 0" is how an hour disappears.


This is the diagnostic half of #7 — that's the bug which produces the -6, and this is what makes it legible. Independent of it, though; either can go in alone.

A failed spawn reported "pty_spawn failed with error -6: errno -6", which names
nothing and is actively misleading -- errno is never negative, so the number is
not an errno at all.

Two changes.

The message now carries all three fields of the result struct and the app that
was being spawned, so a failure says what was attempted and what came back
rather than one unexplained number.

And GetErrorMessage stops guessing. The curated switch covered four errno values
and rendered everything else as the bare number, so the failures it could name
were the ordinary ones and the interesting ones fell through. Win32Exception
maps an errno through strerror on Unix, which names all of them.

A non-positive value is called out as not being an errno rather than translated.
That distinction is the useful part: errno is never zero or negative, so seeing
one means the result struct did not carry what the caller expected, which is a
different problem from whatever errno would have described. Getting -6 and
having strerror answer "Undefined error: 0" is how an hour disappears.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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