Module: Stackup::ErrorHandling

Included in:
Stack
Defined in:
lib/stackup/error_handling.rb

Overview

Handle Aws::CloudFormation::Errors::ValidationError.

Instance Method Summary collapse

Instance Method Details

#handling_validation_errorObject

Invoke an Aws::CloudFormation operation

If a ValidationError is raised, check the message; there’s often useful information is hidden inside. If that’s the case, convert it to an appropriate Stackup exception.



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

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