lib/chef/exceptions.rb in chef-10.34.6 vs lib/chef/exceptions.rb in chef-11.0.0.beta.0
- old
+ new
@@ -19,10 +19,25 @@
class Chef
# == Chef::Exceptions
# Chef's custom exceptions are all contained within the Chef::Exceptions
# namespace.
class Exceptions
+
+ # Backcompat with Chef::ShellOut code:
+ require 'mixlib/shellout/exceptions'
+
+ def self.const_missing(const_name)
+ if const_name == :ShellCommandFailed
+ Chef::Log.warn("Chef::Exceptions::ShellCommandFailed is deprecated, use Mixlib::ShellOut::ShellCommandFailed")
+ called_from = caller[0..3].inject("Called from:\n") {|msg, trace_line| msg << " #{trace_line}\n" }
+ Chef::Log.warn(called_from)
+ Mixlib::ShellOut::ShellCommandFailed
+ else
+ super
+ end
+ end
+
class Application < RuntimeError; end
class Cron < RuntimeError; end
class Env < RuntimeError; end
class Exec < RuntimeError; end
class ErlCall < RuntimeError; end
@@ -37,11 +52,10 @@
class CannotDetermineNodeName < RuntimeError; end
class User < RuntimeError; end
class Group < RuntimeError; end
class Link < RuntimeError; end
class Mount < RuntimeError; end
- class CouchDBNotFound < RuntimeError; end
class PrivateKeyMissing < RuntimeError; end
class CannotWritePrivateKey < RuntimeError; end
class RoleNotFound < RuntimeError; end
class ValidationFailed < ArgumentError; end
class InvalidPrivateKey < ArgumentError; end
@@ -58,14 +72,12 @@
class InvalidCommandOption < RuntimeError; end
class CommandTimeout < RuntimeError; end
class RequestedUIDUnavailable < RuntimeError; end
class InvalidHomeDirectory < ArgumentError; end
class DsclCommandFailed < RuntimeError; end
- class PlistUtilCommandFailed < RuntimeError; end
class UserIDNotFound < ArgumentError; end
class GroupIDNotFound < ArgumentError; end
- class ConflictingMembersInGroup < ArgumentError; end
class InvalidResourceReference < RuntimeError; end
class ResourceNotFound < RuntimeError; end
class InvalidResourceSpecification < ArgumentError; end
class SolrConnectionError < RuntimeError; end
class IllegalChecksumRevert < RuntimeError; end
@@ -80,11 +92,12 @@
# Errors originating from calls to the Win32 API
class Win32APIError < RuntimeError; end
# Thrown when Win32 API layer binds to non-existent Win32 function. Occurs
# when older versions of Windows don't support newer Win32 API functions.
class Win32APIFunctionNotImplemented < NotImplementedError; end
-
+ # Attempting to run windows code on a not-windows node
+ class Win32NotWindows < RuntimeError; end
class ObsoleteDependencySyntax < ArgumentError; end
class InvalidDataBagPath < ArgumentError; end
# A different version of a cookbook was added to a
# VersionedRecipeList than the one already there.
@@ -97,18 +110,40 @@
# match OP VERSION. ArgumentError?
class InvalidVersionConstraint < ArgumentError; end
# File operation attempted but no permissions to perform it
class InsufficientPermissions < RuntimeError; end
-
+
# Ifconfig failed
class Ifconfig < RuntimeError; end
- # Backcompat with Chef::ShellOut code:
- require 'mixlib/shellout/exceptions'
- class ShellCommandFailed < Mixlib::ShellOut::ShellCommandFailed; end
+ # Invalid "source" parameter to a remote_file resource
+ class InvalidRemoteFileURI < ArgumentError; end
+ # Node::Attribute computes the merged version of of attributes
+ # and makes it read-only. Attempting to modify a read-only
+ # attribute will cause this error.
+ class ImmutableAttributeModification < NoMethodError; end
+
+ # Merged node attributes are invalidated when the component
+ # attributes are updated. Attempting to read from a stale copy
+ # of merged attributes will trigger this error.
+ class StaleAttributeRead < StandardError; end
+
+ #Registry Helper throws the following errors
+ class Win32RegArchitectureIncorrect < RuntimeError; end
+ class Win32RegHiveMissing < ArgumentError; end
+ class Win32RegKeyMissing < RuntimeError; end
+ class Win32RegValueMissing < RuntimeError; end
+ class Win32RegDataMissing < RuntimeError; end
+ class Win32RegValueExists < RuntimeError; end
+ class Win32RegNoRecursive < ArgumentError; end
+ class Win32RegTypeDoesNotExist < ArgumentError; end
+ class Win32RegBadType < ArgumentError; end
+ class Win32RegBadValueSize < ArgumentError; end
+ class Win32RegTypesMismatch < ArgumentError; end
+
class MissingRole < RuntimeError
NULL = Object.new
attr_reader :expansion
@@ -126,11 +161,54 @@
end
end
end
+ # Exception class for collecting multiple failures. Used when running
+ # delayed notifications so that chef can process each delayed
+ # notification even if chef client or other notifications fail.
+ class MultipleFailures < StandardError
+ def initialize(*args)
+ super
+ @all_failures = []
+ end
+ def message
+ base = "Multiple failures occurred:\n"
+ @all_failures.inject(base) do |message, (location, error)|
+ message << "* #{error.class} occurred in #{location}: #{error.message}\n"
+ end
+ end
+
+ def client_run_failure(exception)
+ set_backtrace(exception.backtrace)
+ @all_failures << [ "chef run", exception ]
+ end
+
+ def notification_failure(exception)
+ @all_failures << [ "delayed notification", exception ]
+ end
+
+ def raise!
+ unless empty?
+ raise self.for_raise
+ end
+ end
+
+ def empty?
+ @all_failures.empty?
+ end
+
+ def for_raise
+ if @all_failures.size == 1
+ @all_failures[0][1]
+ else
+ self
+ end
+ end
+ end
+
class CookbookVersionSelection
# Compound exception: In run_list expansion and resolution,
# run_list items referred to cookbooks that don't exist and/or
# have no versions available.
@@ -187,15 +265,10 @@
"most_constrained_cookbooks" => most_constrained_cookbooks
}
result.to_json(*a)
end
end
- end # CookbookVersionSelection
- # When the server sends a redirect, RFC 2616 states a user-agent should
- # not follow it with a method other than GET or HEAD, unless a specific
- # action is taken by the user. A redirect received as response to a
- # non-GET and non-HEAD request will thus raise an InvalidRedirect.
- class InvalidRedirect < StandardError; end
+ end # CookbookVersionSelection
end
end