class ProcessExecuter::Error
Base class for all ProcessExecuter::Command errors
It is recommended to rescue ‘ProcessExecuter::Error` to catch any runtime error raised by this gem unless you need more specific error handling.
Custom errors are arranged in the following class hierarchy:
“‘text ::StandardError
└─> Error ├─> CommandError │ ├─> FailedError │ └─> SignaledError │ └─> TimeoutError └─> ProcessIOError
“‘
| Error
Class | Description | | — | — | | ‘Error` | This catch-all error serves as the base class for other custom errors. | | `CommandError` | A subclass of this error is raised when there is a problem executing a command. | | `FailedError` | Raised when the command exits with a non-zero status code. | | `SignaledError` | Raised when the command is terminated as a result of receiving a signal. This could happen if the process is forcibly terminated or if there is a serious system error. | | `TimeoutError` | This is a specific type of `SignaledError` that is raised when the command times out and is killed via the SIGKILL signal. Raised when the operation takes longer than the specified timeout duration (if provided). | | `ProcessIOError` | Raised when an error was encountered reading or writing to the command’s subprocess. |
@example Rescuing any error
begin ProcessExecuter.run_command('git', 'status') rescue ProcessExecuter::Error => e puts "An error occurred: #{e.message}" end
@example Rescuing a timeout error
begin timeout_after = 0.1 # seconds ProcessExecuter.run_command('sleep', '1', timeout_after:) rescue ProcessExecuter::TimeoutError => e # Catch the more specific error first! puts "Command took too long and timed out: #{e}" rescue ProcessExecuter::Error => e puts "Some other error occured: #{e}" end
@api public