Class: Stackup::ErrorMappingProxy

Inherits:
Object
  • Object
show all
Defined in:
lib/stackup/error_mapping_proxy.rb

Overview

An error-mapping proxy for Aws::CloudFormation models.

It exists to convert certain types of ‘ValidationError`, where useful information is hidden inside the “message”, to Stackup exceptions.

Instance Method Summary collapse

Constructor Details

#initialize(delegate) ⇒ ErrorMappingProxy

Returns a new instance of ErrorMappingProxy.



12
13
14
# File 'lib/stackup/error_mapping_proxy.rb', line 12

def initialize(delegate)
  @delegate = delegate
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/stackup/error_mapping_proxy.rb', line 16

def method_missing(*args)
  @delegate.send(*args)
rescue Aws::CloudFormation::Errors::ValidationError => e
  case e.message
  when "No updates are to be performed."
    raise NoUpdateRequired, "no updates are required"
  when /Stack .* does not exist$/
    raise NoSuchStack, "no such stack"
  when / can ?not be /
    raise InvalidStateError, e.message
  else
    raise e
  end
end

Instance Method Details

#respond_to?(method) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/stackup/error_mapping_proxy.rb', line 31

def respond_to?(method)
  @delegate.respond_to?(method)
end