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
228 229 230 231 |
# File 'lib/chef/exceptions.rb', line 228 def initialize(*args) super @all_failures = [] end |
Instance Method Details
#client_run_failure(exception) ⇒ Object
240 241 242 243 |
# File 'lib/chef/exceptions.rb', line 240 def client_run_failure(exception) set_backtrace(exception.backtrace) @all_failures << [ "chef run", exception ] end |
#empty? ⇒ Boolean
255 256 257 |
# File 'lib/chef/exceptions.rb', line 255 def empty? @all_failures.empty? end |
#for_raise ⇒ Object
259 260 261 262 263 264 265 |
# File 'lib/chef/exceptions.rb', line 259 def for_raise if @all_failures.size == 1 @all_failures[0][1] else self end end |
#message ⇒ Object
233 234 235 236 237 238 |
# File 'lib/chef/exceptions.rb', line 233 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
245 246 247 |
# File 'lib/chef/exceptions.rb', line 245 def notification_failure(exception) @all_failures << [ "delayed notification", exception ] end |
#raise! ⇒ Object
249 250 251 252 253 |
# File 'lib/chef/exceptions.rb', line 249 def raise! unless empty? raise self.for_raise end end |