class Git::Error
Base class for all custom git module errors
The git gem will only raise an `ArgumentError` or an error that is a subclass of `Git::Error`. It does not explicitly raise any other types of errors.
It is recommended to rescue `Git::Error` to catch any runtime error raised by this gem unless you need more specific error handling.
Git's custom errors are arranged in the following class heirarchy:
“`text StandardError └─> Git::Error
├─> Git::CommandLineError │ ├─> Git::FailedError │ └─> Git::SignaledError │ └─> Git::TimeoutError ├─> Git::ProcessIOError └─> Git::UnexpectedResultError
“`
| Error Class | Description | | — | — | | `Error` | This catch-all error serves as the base class for other custom errors raised by the git gem. | | `CommandLineError` | A subclass of this error is raised when there is a problem executing the git command line. | | `FailedError` | This error is raised when the git command line exits with a non-zero status code that is not expected by the git gem. | | `SignaledError` | This error is raised when the git command line 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 git command line operation times out and is killed via the SIGKILL signal. This happens if the operation takes longer than the timeout duration configured in `Git.config.timeout` or via the `:timeout` parameter given in git methods that support timeouts. | | `ProcessIOError` | An error was encountered reading or writing to a subprocess. | | `UnexpectedResultError` | The command line ran without error but did not return the expected results. |
@example Rescuing a generic error
begin # some git operation rescue Git::Error => e puts "An error occurred: #{e.message}" end
@example Rescuing a timeout error
begin timeout_duration = 0.001 # seconds repo = Git.clone('https://github.com/ruby-git/ruby-git', 'ruby-git-temp', timeout: timeout_duration) rescue Git::TimeoutError => e # Catch the more specific error first! puts "Git clone took too long and timed out #{e}" rescue Git::Error => e puts "Received the following error: #{e}" end
@see Git::CommandLineError @see Git::FailedError @see Git::SignaledError @see Git::TimeoutError @see Git::ProcessIOError @see Git::UnexpectedResultError
@api public