Class: ChefCore::Errors::StandardErrorResolver

Inherits:
Object
  • Object
show all
Defined in:
lib/chef_core/errors/standard_error_resolver.rb

Overview

Provides mappings of common errors that we don’t explicitly handle, but can offer expanded help text around.

Class Method Summary collapse

Class Method Details

.depsObject



31
32
33
34
35
# File 'lib/chef_core/errors/standard_error_resolver.rb', line 31

def self.deps
  # Avoid loading additional includes until they're needed
  require "socket"
  require "openssl"
end

.resolve_exception(exception) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/chef_core/errors/standard_error_resolver.rb', line 6

def self.resolve_exception(exception)
  deps
  case exception
  when OpenSSL::SSL::SSLError
    if exception.message =~ /SSL.*verify failed.*/
      id = "CHEFNET002"
    end
  when SocketError then id = "CHEFNET001"
  end
  if id.nil?
    exception
  else
    ChefCore::Error.new(id, exception.message)
  end
end

.unwrap_exception(wrapper) ⇒ Object



27
28
29
# File 'lib/chef_core/errors/standard_error_resolver.rb', line 27

def self.unwrap_exception(wrapper)
  resolve_exception(wrapper.contained_exception)
end

.wrap_exception(original, target_host = nil) ⇒ Object



22
23
24
25
# File 'lib/chef_core/errors/standard_error_resolver.rb', line 22

def self.wrap_exception(original, target_host = nil)
  resolved_exception = resolve_exception(original)
  WrappedError.new(resolved_exception, target_host)
end