Sha256: 4ab049f0f9c9c42116bfc813c2a78840c6c9db129c4557e3286a5da695dc6100

Contents?: true

Size: 1.69 KB

Versions: 10

Compression:

Stored size: 1.69 KB

Contents

# frozen_string_literal: true

require 'git/git_execute_error'

module Git
  # This error is raised when a git command exits because of an uncaught signal
  #
  # 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.
  #
  # @api public
  #
  class SignaledError < Git::GitExecuteError
    # Create a SignaledError object
    #
    # @example
    #   `kill -9 $$` # set $? appropriately for this example
    #   result = Git::CommandLineResult.new(%w[git status], $?, '', "killed")
    #   error = Git::SignaledError.new(result)
    #   error.message #=>
    #     "[\"git\", \"status\"]\nstatus: pid 88811 SIGKILL (signal 9)\nstderr: \"killed\""
    #
    # @param result [Git::CommandLineResult] the result of the git command including the git command, status, stdout, and stderr
    #
    def initialize(result)
      super("#{result.git_cmd}\nstatus: #{result.status}\nstderr: #{result.stderr.inspect}")
      @result = result
    end

    # @attribute [r] result
    #
    # The result of the git command including the git command, status, and output
    #
    # @example
    #   `kill -9 $$` # set $? appropriately for this example
    #   result = Git::CommandLineResult.new(%w[git status], $?, '', "killed")
    #   error = Git::SignaledError.new(result)
    #   error.result #=>
    #     #<Git::CommandLineResult:0x000000010470f6e8
    #       @git_cmd=["git", "status"],
    #       @status=#<Process::Status: pid 88811 SIGKILL (signal 9)>,
    #       @stderr="killed",
    #       @stdout="">
    #
    # @return [Git::CommandLineResult]
    #
    attr_reader :result
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
git-2.0.0.pre1 lib/git/signaled_error.rb
git-1.19.1 lib/git/signaled_error.rb
git-1.19.0 lib/git/signaled_error.rb
git-1.18.0 lib/git/signaled_error.rb
git-1.17.2 lib/git/signaled_error.rb
git-1.17.1 lib/git/signaled_error.rb
git-1.17.0 lib/git/signaled_error.rb
git-1.16.0 lib/git/signaled_error.rb
git-1.15.0 lib/git/signaled_error.rb
git-1.14.0 lib/git/signaled_error.rb