Skip to content

Leave the pid out of the failure message - #34

Merged
orien merged 1 commit into
mainfrom
exception-message
Nov 29, 2026
Merged

orien merged 1 commit into
mainfrom
exception-message

Conversation

@orien

@orien orien commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Context

When execute! raises CommandFailedException, the message interpolates the Process::Status, whose to_s starts with the child's pid:

Shell command ["false"] failed with status pid 95983 exit 1

It reads as though the pid were the status. Every occurrence of the same failure also has a different message, so error trackers and log deduplication, which group by message, can't group them.

PE-8869

Change

Composes the message from the exit status or the terminating signal, keeping the failed with prefix:

Shell command ["false"] failed with status 1
Shell command ["sh", "-c", "kill -TERM $$"] failed with SIGTERM
  • A signal Ruby has no name for, such as a Linux real-time signal, is given by number: failed with signal 34.
  • A command given without a status gets Shell command ["false"] failed.
  • The specs now pin the whole message in each case.
  • The class doc states the format, and the README example prints the message in place of the status.

Considerations

  • The message format changes for 2.0.0, so it needs a line in the release notes. Code that matches only on failed with status still matches a non-zero exit, but not a signal.
  • The pid is still available through e.status.pid.

@orien
orien force-pushed the exception-message branch from 9fe8d31 to 0ec80df Compare November 29, 2026 13:08
@orien
orien marked this pull request as ready for review November 29, 2026 13:10
@orien
orien force-pushed the exception-message branch 4 times, most recently from 434d8ad to b6127ec Compare November 29, 2026 13:25
The message CommandFailedException composes interpolated the
Process::Status, whose to_s starts with the pid:

  Shell command ["false"] failed with status pid 95983 exit 1

It read as though the pid were the status, and each occurrence of the
same failure had a different message, so error trackers and log
deduplication could not group them.

Compose it from the exit status or the signal instead, keeping the
"failed with" prefix:

  Shell command ["false"] failed with status 1
  Shell command ["sh", "-c", "kill -TERM $$"] failed with SIGTERM

The pid stays available through the exception's status.
@orien
orien force-pushed the exception-message branch from b6127ec to 16b9425 Compare November 29, 2026 14:09
@orien
orien merged commit eb9d6a9 into main Nov 29, 2026
16 checks passed
@orien
orien deleted the exception-message branch November 29, 2026 14:14
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