Exception: Chef::Exceptions::MultipleFailures
- Inherits:
-
StandardError
- Object
- StandardError
- 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.
295 296 297 298 |
# File 'lib/chef/exceptions.rb', line 295 def initialize(*args) super @all_failures = [] end |
Instance Method Details
#client_run_failure(exception) ⇒ Object
307 308 309 310 |
# File 'lib/chef/exceptions.rb', line 307 def client_run_failure(exception) set_backtrace(exception.backtrace) @all_failures << [ "chef run", exception ] end |
#empty? ⇒ Boolean
322 323 324 |
# File 'lib/chef/exceptions.rb', line 322 def empty? @all_failures.empty? end |
#for_raise ⇒ Object
326 327 328 329 330 331 332 |
# File 'lib/chef/exceptions.rb', line 326 def for_raise if @all_failures.size == 1 @all_failures[0][1] else self end end |
#message ⇒ Object
300 301 302 303 304 305 |
# File 'lib/chef/exceptions.rb', line 300 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
312 313 314 |
# File 'lib/chef/exceptions.rb', line 312 def notification_failure(exception) @all_failures << [ "delayed notification", exception ] end |
#raise! ⇒ Object
316 317 318 319 320 |
# File 'lib/chef/exceptions.rb', line 316 def raise! unless empty? raise self.for_raise end end |