Exception: R10K::Git::NonexistentHashError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/r10k/git/errors.rb

Constant Summary collapse

HASHLIKE =
%r[[A-Fa-f0-9]]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(msg = nil, git_dir = nil) ⇒ NonexistentHashError

Returns a new instance of NonexistentHashError.



9
10
11
12
13
# File 'lib/r10k/git/errors.rb', line 9

def initialize(msg = nil, git_dir = nil)
  super(msg)

  @git_dir = git_dir
end

Instance Attribute Details

#git_dirObject (readonly)

Returns the value of attribute git_dir.



7
8
9
# File 'lib/r10k/git/errors.rb', line 7

def git_dir
  @git_dir
end

#hashObject (readonly)

Raised when a hash was requested that can’t be found in the repository



6
7
8
# File 'lib/r10k/git/errors.rb', line 6

def hash
  @hash
end

Instance Method Details

#messageObject

Print a friendly error message if an object hash is given as the message



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/r10k/git/errors.rb', line 18

def message
  msg = super
  if msg and msg.match(HASHLIKE)
    msg = "Could not locate hash #{msg.inspect} in repository"
  elsif msg.nil?
    msg = "Could not locate hash in repository"
  end

  if @git_dir
    msg << " at #{@git_dir}. (Does the remote repository need to be updated?)"
  end

  msg
end