Class: MovableInk::AWS::Errors::ExpectedError
- Inherits:
-
Object
- Object
- MovableInk::AWS::Errors::ExpectedError
- Defined in:
- lib/movable_ink/aws/errors.rb
Instance Method Summary collapse
-
#initialize(error_class, message_patterns = []) ⇒ ExpectedError
constructor
A new instance of ExpectedError.
- #match?(exception) ⇒ Boolean
Constructor Details
#initialize(error_class, message_patterns = []) ⇒ ExpectedError
Returns a new instance of ExpectedError.
14 15 16 17 18 |
# File 'lib/movable_ink/aws/errors.rb', line 14 def initialize(error_class, = []) @error_class = error_class .each { |pattern| raise StandardError.new("Invalid message pattern provided #{pattern.inspect}") unless pattern.class == Regexp } @message_patterns = end |
Instance Method Details
#match?(exception) ⇒ Boolean
20 21 22 23 24 25 |
# File 'lib/movable_ink/aws/errors.rb', line 20 def match?(exception) return false unless exception.class == @error_class return true if @message_patterns.length == 0 @message_patterns.each {|pattern| return true if exception..match(pattern) } false end |