summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-10-20 16:06:34 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-10-26 16:21:06 -0700
commit324fddbb0d2d6ecdd63c0044eaf07e18d1e2de7b (patch)
tree355abebb4787d40a90c6e9ee1f327df6978ba860 /lib
parent4e61b02930ac7b8db3fd040ced2b110bfce54c9f (diff)
downloadchef-324fddbb0d2d6ecdd63c0044eaf07e18d1e2de7b.tar.gz
improve error message, add more tests
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/cookbook/metadata.rb6
-rw-r--r--lib/chef/exceptions.rb12
2 files changed, 10 insertions, 8 deletions
diff --git a/lib/chef/cookbook/metadata.rb b/lib/chef/cookbook/metadata.rb
index 93c62862a1..6c5663ae40 100644
--- a/lib/chef/cookbook/metadata.rb
+++ b/lib/chef/cookbook/metadata.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: AJ Christensen (<aj@opscode.com>)
# Author:: Seth Falcon (<seth@opscode.com>)
-# Copyright:: Copyright 2008-2010 Opscode, Inc.
+# Copyright:: Copyright 2008-2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -652,13 +652,13 @@ class Chef
def validate_ohai_version!
unless gem_dep_matches?("ohai", Gem::Version.new(Ohai::VERSION), *ohai_versions)
- raise Exceptions::CookbookOhaiVersionMismatch.new(Ohai::VERSION, *ohai_versions)
+ raise Exceptions::CookbookOhaiVersionMismatch.new(Ohai::VERSION, name, version, *ohai_versions)
end
end
def validate_chef_version!
unless gem_dep_matches?("chef", Gem::Version.new(Chef::VERSION), *chef_versions)
- raise Exceptions::CookbookChefVersionMismatch.new(Chef::VERSION, *chef_versions)
+ raise Exceptions::CookbookChefVersionMismatch.new(Chef::VERSION, name, version, *chef_versions)
end
end
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
index ef73caa276..8172311dd6 100644
--- a/lib/chef/exceptions.rb
+++ b/lib/chef/exceptions.rb
@@ -2,7 +2,7 @@
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Seth Falcon (<seth@opscode.com>)
# Author:: Kyle Goodwin (<kgoodwin@primerevenue.com>)
-# Copyright:: Copyright 2008-2010 Opscode, Inc.
+# Copyright:: Copyright 2008-2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -483,14 +483,16 @@ class Chef
end
class CookbookChefVersionMismatch < RuntimeError
- def initialize(chef_version, *constraints)
- super "chef version #{chef_version} is badness"
+ def initialize(chef_version, cookbook_name, cookbook_version, *constraints)
+ constraint_str = constraints.map { |c| c.requirement.as_list.to_s }.join(', ')
+ super "Cookbook '#{cookbook_name}' version '#{cookbook_version}' depends on chef version #{constraint_str}, but the running chef version is #{chef_version}"
end
end
class CookbookOhaiVersionMismatch < RuntimeError
- def initialize(ohai_version, *constraints)
- super "ohai version #{ohai_version} is badness"
+ def initialize(ohai_version, cookbook_name, cookbook_version, *constraints)
+ constraint_str = constraints.map { |c| c.requirement.as_list.to_s }.join(', ')
+ super "Cookbook '#{cookbook_name}' version '#{cookbook_version}' depends on ohai version #{constraint_str}, but the running ohai version is #{ohai_version}"
end
end