module ChefCLI::NestedExceptionWithInspector

def extended_error_info

def extended_error_info
  inspector.extended_error_info
end

def initialize(message, cause)

def initialize(message, cause)
  super(message)
  @message = message
  @inspector = inspector_for(cause)
  @cause = cause
end

def inspector_for(exception)

def inspector_for(exception)
  if exception.respond_to?(:response)
    ServiceExceptionInspectors::HTTP.new(exception)
  else
    ServiceExceptionInspectors::Base.new(exception)
  end
end

def message

def message
  @message
end

def reason

def reason
  "(#{cause.class.name}) #{inspector.message}"
end

def to_s

def to_s
  "#{message}\nCaused by: #{reason}"
end