Exception: Git::TimeoutError

Inherits:
SignaledError show all
Defined in:
lib/git/errors.rb

Overview

This error is raised when a git command takes longer than the configured timeout

The git command executed, status, stdout, and stderr, and the timeout duration are available from this object.

result.status.timeout? will be true

Instance Attribute Summary collapse

Attributes inherited from CommandLineError

#result

Instance Method Summary collapse

Constructor Details

#initialize(result, timeout_duration) ⇒ TimeoutError

Create a TimeoutError object

Examples:

command = %w[sleep 10]
timeout_duration = 1
status = ProcessExecuter.spawn(*command, timeout: timeout_duration)
result = Git::CommandLineResult.new(command, status, 'stdout', 'err output')
error = Git::TimeoutError.new(result, timeout_duration)
error.error_message #=> '["sleep", "10"], status: pid 70144 SIGKILL (signal 9), stderr: "err output", timed out after 1s'

Parameters:

  • result (Git::CommandLineResult)

    the result of the git command including the git command, status, stdout, and stderr

  • timeout_duration (Numeric)

    the amount of time the subprocess was allowed to run before being killed



166
167
168
169
# File 'lib/git/errors.rb', line 166

def initialize(result, timeout_duration)
  @timeout_duration = timeout_duration
  super(result)
end

Instance Attribute Details

#timeout_durationNumeric (readonly)

The amount of time the subprocess was allowed to run before being killed

Examples:

`kill -9 $$` # set $? appropriately for this example
result = Git::CommandLineResult.new(%w[git status], $?, '', "killed")
error = Git::TimeoutError.new(result, 10)
error.timeout_duration #=> 10

Returns:

  • (Numeric)


192
193
194
# File 'lib/git/errors.rb', line 192

def timeout_duration
  @timeout_duration
end

Instance Method Details

#error_messageString

The human readable representation of this error

Examples:

error.error_message #=> '["sleep", "10"], status: pid 88811 SIGKILL (signal 9), stderr: "err output", timed out after 1s'

Returns:

  • (String)


178
179
180
# File 'lib/git/errors.rb', line 178

def error_message = <<~MESSAGE.chomp
  #{super}, timed out after #{timeout_duration}s
MESSAGE