Exception: Chef::Exceptions::MultipleFailures
- Defined in:
- lib/chef/exceptions.rb
Overview
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.
Instance Method Summary collapse
- #client_run_failure(exception) ⇒ Object
- #empty? ⇒ Boolean
- #for_raise ⇒ Object
-
#initialize(*args) ⇒ MultipleFailures
constructor
A new instance of MultipleFailures.
- #message ⇒ Object
- #notification_failure(exception) ⇒ Object
- #raise! ⇒ Object
Constructor Details
#initialize(*args) ⇒ MultipleFailures
Returns a new instance of MultipleFailures.
190 191 192 193 |
# File 'lib/chef/exceptions.rb', line 190 def initialize(*args) super @all_failures = [] end |
Instance Method Details
#client_run_failure(exception) ⇒ Object
202 203 204 205 |
# File 'lib/chef/exceptions.rb', line 202 def client_run_failure(exception) set_backtrace(exception.backtrace) @all_failures << [ "chef run", exception ] end |
#empty? ⇒ Boolean
217 218 219 |
# File 'lib/chef/exceptions.rb', line 217 def empty? @all_failures.empty? end |
#for_raise ⇒ Object
221 222 223 224 225 226 227 |
# File 'lib/chef/exceptions.rb', line 221 def for_raise if @all_failures.size == 1 @all_failures[0][1] else self end end |
#message ⇒ Object
195 196 197 198 199 200 |
# File 'lib/chef/exceptions.rb', line 195 def base = "Multiple failures occurred:\n" @all_failures.inject(base) do |, (location, error)| << "* #{error.class} occurred in #{location}: #{error.message}\n" end end |
#notification_failure(exception) ⇒ Object
207 208 209 |
# File 'lib/chef/exceptions.rb', line 207 def notification_failure(exception) @all_failures << [ "delayed notification", exception ] end |
#raise! ⇒ Object
211 212 213 214 215 |
# File 'lib/chef/exceptions.rb', line 211 def raise! unless empty? raise self.for_raise end end |