lib/berkshelf/errors.rb in berkshelf-3.0.0.beta1 vs lib/berkshelf/errors.rb in berkshelf-3.0.0.beta2
- old
+ new
@@ -18,14 +18,28 @@
def to_s
'Function must be implemented on includer'
end
end
- class BerksfileNotFound < BerkshelfError; status_code(100); end
+ class BerksfileNotFound < BerkshelfError
+ status_code(100)
+
+ # @param [#to_s] filepath
+ # the path where a Berksfile was not found
+ def initialize(filepath)
+ @filepath = File.dirname(File.expand_path(filepath)) rescue filepath
+ end
+
+ def to_s
+ "No Berksfile or Berksfile.lock found at '#{@filepath}'!"
+ end
+ end
+
class NoVersionForConstraints < BerkshelfError; status_code(101); end
class DuplicateLocationDefined < BerkshelfError; status_code(102); end
class CookbookNotFound < BerkshelfError; status_code(103); end
+
class GitError < BerkshelfError
status_code(104)
# @param [#to_s] stderr
# the error that came from stderr
@@ -98,10 +112,27 @@
end
end
class CookbookSyntaxError < BerkshelfError; status_code(107); end
+ class MercurialError < BerkshelfError
+ status_code(108);
+ end
+
+ class InvalidHgURI < BerkshelfError
+ status_code(110)
+
+ # @param [String] uri
+ def initialize(uri)
+ @uri = uri
+ end
+
+ def to_s
+ "'#{@uri}' is not a valid Mercurial URI"
+ end
+ end
+
class InvalidGitURI < BerkshelfError
status_code(110)
# @param [String] uri
def initialize(uri)
@@ -124,10 +155,18 @@
def to_s
"'#{@protocol}' is not supported for the 'github' location key - please use 'git' instead"
end
end
+ class MercurialNotFound < BerkshelfError
+ status_code(111)
+
+ def to_s
+ 'Could not find a Mercurial executable in your path - please add it and try again'
+ end
+ end
+
class GitNotFound < BerkshelfError
status_code(110)
def to_s
'Could not find a Git executable in your path - please add it and try again'
@@ -207,11 +246,27 @@
end
class ConfigExists < BerkshelfError; status_code(116); end
class ConfigurationError < BerkshelfError; status_code(117); end
class InsufficientPrivledges < BerkshelfError; status_code(119); end
- class DependencyNotFound < BerkshelfError; status_code(120); end
+
+ class DependencyNotFound < BerkshelfError
+ status_code(120)
+
+ # @param [String, Array<String>] cookbooks
+ # the list of cookbooks that were not defined
+ def initialize(cookbooks)
+ @cookbooks = Array(cookbooks)
+ end
+
+ def to_s
+ list = @cookbooks.collect {|c| "'#{c}'" }
+ "Could not find cookbook(s) #{list.join(', ')} in any of the configured" <<
+ " dependencies. #{list.size == 1 ? 'Is it' : 'Are they' } in your Berksfile?"
+ end
+ end
+
class ValidationFailed < BerkshelfError; status_code(121); end
class InvalidVersionConstraint < BerkshelfError; status_code(122); end
class CommunitySiteError < BerkshelfError; status_code(123); end
class CookbookValidationFailure < BerkshelfError
@@ -232,12 +287,26 @@
end
class ClientKeyFileNotFound < BerkshelfError; status_code(125); end
class UploadFailure < BerkshelfError; end
- class FrozenCookbook < UploadFailure; status_code(126); end
+ class FrozenCookbook < UploadFailure
+ status_code(126)
+
+ # @param [CachedCookbook] cookbook
+ def initialize(cookbook)
+ @cookbook = cookbook
+ end
+
+ def to_s
+ "The cookbook #{@cookbook.cookbook_name} (#{@cookbook.version})" <<
+ " already exists and is frozen on the Chef Server. Use the --force" <<
+ " option to override."
+ end
+ end
+
class OutdatedDependency < BerkshelfError
status_code(128)
# @param [Berkshelf::Dependency] locked_dependency
# the locked dependency
@@ -402,6 +471,8 @@
msg + " #{reason}." unless reason.nil?
end
end
class DuplicateDemand < BerkshelfError; status_code(138); end
+ class VendorError < BerkshelfError; status_code(139); end
+ class LockfileNotFound < BerkshelfError; status_code(140); end
end