Exception: Puppet::ModuleTool::Errors::VersionAlreadyInstalledError

Inherits:
UpgradeError show all
Defined in:
lib/puppet/module_tool/errors/upgrader.rb

Instance Attribute Summary collapse

Attributes inherited from Error

#original

Instance Method Summary collapse

Methods inherited from ModuleToolError

#v, #vstring

Constructor Details

#initialize(options) ⇒ VersionAlreadyInstalledError

Returns a new instance of VersionAlreadyInstalledError.



13
14
15
16
17
18
19
20
21
# File 'lib/puppet/module_tool/errors/upgrader.rb', line 13

def initialize(options)
  @module_name       = options[:module_name]
  @requested_version = options[:requested_version]
  @installed_version = options[:installed_version]
  @dependency_name   = options[:dependency_name]
  @newer_versions    = options[:newer_versions]
  @possible_culprits = options[:possible_culprits]
  super _("Could not upgrade '%{module_name}'; more recent versions not found") % { module_name: @module_name }
end

Instance Attribute Details

#newer_versionsObject (readonly)

Returns the value of attribute newer_versions.



11
12
13
# File 'lib/puppet/module_tool/errors/upgrader.rb', line 11

def newer_versions
  @newer_versions
end

Instance Method Details

#multilineObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/puppet/module_tool/errors/upgrader.rb', line 23

def multiline
  message = []
  message << _("Could not upgrade module '%{module_name}' (%{version})") % { module_name: @module_name, version: vstring }
  if @newer_versions.empty?
    message << _("  The installed version is already the latest version matching %{version}") % { version: vstring }
  else
    message << _("  There are %{count} newer versions") % { count: @newer_versions.length }
    message << _("    No combination of dependency upgrades would satisfy all dependencies")
    unless @possible_culprits.empty?
      message << _("    Dependencies will not be automatically upgraded across major versions")
      message << _("    Upgrading one or more of these modules may permit the upgrade to succeed:")
      @possible_culprits.each do |name|
        message << "    - #{name}"
      end
    end
  end
  message << _("    Use `puppet module upgrade --force` to upgrade only this module")
  message.join("\n")
end