Class: ToeTag::MessageSpec
- Inherits:
-
ExceptionSpec
- Object
- Module
- ExceptionSpec
- ToeTag::MessageSpec
- Defined in:
- lib/toe_tag.rb
Overview
Wraps an exception class to allow matching against the message, too. Intended to be used in rescue clauses, for cases where one exception class (ActiveRecord::StatementInvalid, I’m looking at you) represents a host of underlying issues.
The recommended usage is to assign these to constants and treat them as a sort of meta-exception. This may be useful in combination with ExceptionCategory.
Instance Method Summary collapse
- #===(except) ⇒ Object
-
#initialize(message, exception = StandardError) ⇒ MessageSpec
constructor
A new instance of MessageSpec.
Methods included from ExceptionBehavior
Constructor Details
#initialize(message, exception = StandardError) ⇒ MessageSpec
Returns a new instance of MessageSpec.
126 127 128 129 |
# File 'lib/toe_tag.rb', line 126 def initialize(, exception = StandardError) self.exception = exception self. = end |
Instance Method Details
#===(except) ⇒ Object
131 132 133 |
# File 'lib/toe_tag.rb', line 131 def ===(except) exception === except && === except. end |