lib/berkshelf/errors.rb in berkshelf-3.2.2 vs lib/berkshelf/errors.rb in berkshelf-3.2.3

- old
+ new

@@ -13,10 +13,11 @@ class DeprecatedError < BerkshelfError; set_status_code(10); end class InternalError < BerkshelfError; set_status_code(99); end class ArgumentError < InternalError; end class AbstractFunction < InternalError; end + class ConfigurationError < InternalError; end class BerksfileNotFound < BerkshelfError set_status_code(100) # @param [#to_s] filepath @@ -26,10 +27,12 @@ end def to_s "No Berksfile or Berksfile.lock found at '#{@filepath}'!" end + + alias_method :message, :to_s end class CookbookNotFound < BerkshelfError set_status_code(103) @@ -44,10 +47,12 @@ "Cookbook '#{@name}' (#{@version}) not found #{@location}!" else "Cookbook '#{@name}' not found #{@location}!" end end + + alias_method :message, :to_s end class DuplicateDependencyDefined < BerkshelfError set_status_code(105) @@ -59,10 +64,12 @@ out = "Your Berksfile contains multiple entries named " out << "'#{@name}'. Please remove duplicate dependencies, or put them in " out << "different groups." out end + + alias_method :message, :to_s end class NoSolutionError < BerkshelfError set_status_code(106) @@ -76,10 +83,12 @@ def to_s @original_exception.to_s + "Unable to find a solution for demands: #{demands.join(', ')}" end + + alias_method :message, :to_s end class CookbookSyntaxError < BerkshelfError; set_status_code(107); end class ConstraintNotSatisfied < BerkshelfError; set_status_code(111); end class BerksfileReadError < BerkshelfError @@ -106,10 +115,12 @@ "An error occurred while reading the Berksfile:", "", " #{@error_message}", ].join("\n") end + + alias_method :message, :to_s end class MismatchedCookbookName < BerkshelfError set_status_code(114) @@ -134,10 +145,12 @@ out << "NOTE: If you do not explicitly set the 'name' attribute in the " out << "metadata, the name of the directory will be used instead. This " out << "is often a cause of confusion for dependency solving." out end + + alias_method :message, :to_s end class InvalidConfiguration < BerkshelfError set_status_code(115) @@ -153,10 +166,12 @@ end end out.strip end + + alias_method :message, :to_s end class InsufficientPrivledges < BerkshelfError set_status_code(119) @@ -167,10 +182,12 @@ def to_s "You do not have permission to write to '#{@path}'! Please chown the " \ "path to the current user, chmod the permissions to include the " \ "user, or choose a different path." end + + alias_method :message, :to_s end class DependencyNotFound < BerkshelfError set_status_code(120) @@ -195,10 +212,12 @@ out << "`berks install` to download and install the missing " out << "dependencies." out end end + + alias_method :message, :to_s end class CommunitySiteError < BerkshelfError set_status_code(123) @@ -209,10 +228,12 @@ def to_s "An unexpected error occurred retrieving #{@message} from the cookbook " \ "site at '#{@api_uri}'." end + + alias_method :message, :to_s end class CookbookValidationFailure < BerkshelfError set_status_code(124) @@ -226,10 +247,12 @@ end def to_s "The cookbook downloaded for #{@dependency} did not satisfy the constraint." end + + alias_method :message, :to_s end class UploadFailure < BerkshelfError; end class FrozenCookbook < UploadFailure set_status_code(126) @@ -242,10 +265,12 @@ 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 + + alias_method :message, :to_s end class OutdatedDependency < BerkshelfError set_status_code(128) @@ -265,10 +290,12 @@ " In Berksfile.lock:\n" + " #{@locked.name} (#{@locked.version})\n\n" + "Try running `berks update #{@dependency.name}`, which will try to find '#{@dependency.name}' matching " + "'#{@dependency.version_constraint}'." end + + alias_method :message, :to_s end class EnvironmentNotFound < BerkshelfError set_status_code(129) @@ -277,10 +304,12 @@ end def to_s "The environment '#{@environment_name}' does not exist" end + + alias_method :message, :to_s end class ChefConnectionError < BerkshelfError set_status_code(130) @@ -297,10 +326,12 @@ end def to_s "The file at '#{@destination}' is not a known compression type" end + + alias_method :message, :to_s end # Raised when a cookbook or its recipes contain a space or invalid # character in the path. # @@ -323,10 +354,12 @@ " " + @files.map(&:to_s).join("\n "), "", "Please note, spaces are not a valid character in filenames", ].join("\n") end + + alias_method :message, :to_s end class LicenseNotFound < BerkshelfError set_status_code(134) @@ -338,10 +371,12 @@ def to_s "Unknown license: '#{license}'\n" + "Available licenses: #{CookbookGenerator::LICENSES.join(', ')}" end + + alias_method :message, :to_s end # Raised when a cookbook or its recipes contain a space or invalid # character in the path. class ConfigNotFound < BerkshelfError @@ -357,10 +392,12 @@ end def to_s "No #{@type.capitalize} config file found at: '#{@path}'!" end + + alias_method :message, :to_s end class LockfileParserError < BerkshelfError set_status_code(136) @@ -374,10 +411,12 @@ def to_s "Error reading the Berkshelf lockfile:\n\n" \ " #{@original.class}: #{@original.message}" end + + alias_method :message, :to_s end class InvalidSourceURI < BerkshelfError set_status_code(137) @@ -389,10 +428,12 @@ def to_s msg = "'#{@url}' is not a valid Berkshelf source URI." msg << " #{@reason}." unless @reason.nil? msg end + + alias_method :message, :to_s end class DuplicateDemand < BerkshelfError; set_status_code(138); end class LockfileNotFound < BerkshelfError set_status_code(140) @@ -413,10 +454,12 @@ def to_s "The resource at '#{@path}' does not appear to be a valid cookbook. " \ "Does it have a metadata.rb?" end + + alias_method :message, :to_s end class PackageError < BerkshelfError; set_status_code(143); end class LockfileOutOfSync < BerkshelfError @@ -437,10 +480,12 @@ def to_s "The cookbook '#{@name} (#{@version})' is not installed. Please run " \ "`berks install` to download and install the missing dependency." end + + alias_method :message, :to_s end class NoAPISourcesDefined < BerkshelfError set_status_code(146) @@ -475,9 +520,11 @@ def to_s "The Graphviz command `#{@command}` failed to execute properly. Here " \ "is the standard error from the command:\n\n#{@output}" end + + alias_method :message, :to_s end class MissingLockfileCookbookVersion < CookbookNotFound set_status_code(149)