Exception: Git::FailedError

Inherits:
GitExecuteError show all
Defined in:
lib/git/failed_error.rb

Overview

This error is raised when a git command fails

The git command executed, status, stdout, and stderr are available from this object. The #message includes the git command, the status of the process, and the stderr of the process.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(result) ⇒ FailedError

Create a FailedError object

Examples:

`exit 1` # set $? appropriately for this example
result = Git::CommandLineResult.new(%w[git status], $?, '', "failed")
error = Git::FailedError.new(result)
error.message #=>
  "[\"git\", \"status\"]\nstatus: pid 89784 exit 1\nstderr: \"failed\""

Parameters:

  • result (Git::CommandLineResult)

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



27
28
29
30
# File 'lib/git/failed_error.rb', line 27

def initialize(result)
  super("#{result.git_cmd}\nstatus: #{result.status}\nstderr: #{result.stderr.inspect}")
  @result = result
end

Instance Attribute Details

#resultGit::CommandLineResult (readonly)

The result of the git command including the git command and its status and output

Examples:

`exit 1` # set $? appropriately for this example
result = Git::CommandLineResult.new(%w[git status], $?, '', "failed")
error = Git::FailedError.new(result)
error.result #=>
  #<Git::CommandLineResult:0x00000001046bd488
    @git_cmd=["git", "status"],
    @status=#<Process::Status: pid 89784 exit 1>,
    @stderr="failed",
    @stdout="">

Returns:



49
50
51
# File 'lib/git/failed_error.rb', line 49

def result
  @result
end