Exception: Berkshelf::GitError

Inherits:
BerkshelfError show all
Defined in:
lib/berkshelf/errors.rb

Direct Known Subclasses

AmbiguousGitRef, InvalidGitRef

Instance Method Summary collapse

Methods inherited from BerkshelfError

status_code

Constructor Details

#initialize(stderr) ⇒ GitError

Returns a new instance of GitError.

Parameters:

  • stderr (#to_s)

    the error that came from stderr



44
45
46
# File 'lib/berkshelf/errors.rb', line 44

def initialize(stderr)
  @stderr = stderr.to_s
end

Instance Method Details

#headerString

A common header for all git errors. The #to_s method should use this before outputting any specific errors.

Returns:



52
53
54
# File 'lib/berkshelf/errors.rb', line 52

def header
  'An error occurred during Git execution:'
end

#to_sObject



56
57
58
59
60
61
62
63
# File 'lib/berkshelf/errors.rb', line 56

def to_s
  [
    header,
    "",
    "  " + @stderr.to_s.split("\n").map(&:strip).join("\n  "),
    ""
  ].join("\n")
end