Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap errors raised by Process.spawn in a ProcessExecuter::SpawnError #111

Merged
merged 1 commit into from
Apr 1, 2025

Conversation

jcouball
Copy link
Member

@jcouball jcouball commented Apr 1, 2025

The errors raised by Process.spawn for each error condition are inconsistent between different Ruby engines. This change wraps any exception raised by Process.spawn in a ProcessExecuter::SpawnError so that client code can more easily deal with these problems.

The actual error raised by Process.spawn is accessible from the #cause method.

SpawnErrors are not suppressed by the raise_errors: false option.

@jcouball jcouball requested a review from Copilot April 1, 2025 00:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures that any exception raised by Process.spawn is wrapped in a ProcessExecuter::SpawnError so that client code can uniformly handle errors.

  • Introduced a new exception type, SpawnError, in the error hierarchy.
  • Updated methods to rescue and wrap exceptions from Process.spawn.
  • Added tests and documentation updates to reflect the new error behavior.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
spec/process_executer_spawn_and_wait_spec.rb Added test verifying that an invalid command raises a SpawnError.
lib/process_executer/runner.rb Updated documentation to consolidate error types into ProcessExecuter::Error.
lib/process_executer/errors.rb Added SpawnError to the error hierarchy and updated error documentation.
lib/process_executer.rb Wrapped Process.spawn in a rescue block to raise SpawnError.
README.md Updated information to note that SpawnError is not suppressed by raise_errors.

…awnError`

The errors raised by `Process.spawn` for each error condition are inconsistent
between different Ruby engines. This change wraps any exception raised by
`Process.spawn` in a `ProcessExecuter::SpawnError` so that client code can
more easily deal with these problems.

The actual error raised by `Process.spawn` is accessible from the `#cause`
method.

`SpawnError`s are not suppressed by the `raise_errors: false` option.
@jcouball jcouball changed the title Wrap errors raised by Process.spawn in a ProcessExecuter::SpawnError error Wrap errors raised by Process.spawn in a ProcessExecuter::SpawnError Apr 1, 2025
Copy link

codeclimate bot commented Apr 1, 2025

Code Climate has analyzed commit d953359 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 100.0% (100% is the threshold).

This pull request will bring the total coverage in the repository to 100.0% (0.0% change).

View more on Code Climate.

@jcouball jcouball merged commit 3fe114a into main Apr 1, 2025
12 checks passed
@jcouball jcouball deleted the spawn_error branch April 1, 2025 00:41
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