Module: Kitchen::Error

Included in:
StandardError
Defined in:
lib/kitchen/errors.rb

Overview

All Kitchen errors and exceptions.

Author:

Class Method Summary collapse

Class Method Details

.formatted_exception(exception, title = "Exception") ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/kitchen/errors.rb', line 37

def self.formatted_exception(exception, title = "Exception")
  [
    title.center(22, "-"),
    "Class: #{exception.class}",
    "Message: #{exception.message}",
    "".center(22, "-"),
  ]
end

.formatted_trace(exception) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/kitchen/errors.rb', line 26

def self.formatted_trace(exception)
  arr = formatted_exception(exception).dup
  last = arr.pop
  if exception.respond_to?(:original) && exception.original
    arr += formatted_exception(exception.original, "Nested Exception")
    last = arr.pop
  end
  arr += ["Backtrace".center(22, "-"), exception.backtrace, last].flatten
  arr
end