Class: Roby::Queries::CodeErrorMatcher
- Inherits:
-
LocalizedErrorMatcher
- Object
- MatcherBase
- LocalizedErrorMatcher
- Roby::Queries::CodeErrorMatcher
- Defined in:
- lib/roby/queries/code_error_matcher.rb
Overview
Matcher for CodeError exceptions
In addition to the LocalizedError properties, it allows to match properties on the Ruby exception that has been thrown
Instance Attribute Summary collapse
-
#ruby_exception_class ⇒ Object
readonly
Returns the value of attribute ruby_exception_class.
Attributes inherited from LocalizedErrorMatcher
#failure_point_matcher, #model, #original_exception_model
Attributes inherited from MatcherBase
Instance Method Summary collapse
- #===(error) ⇒ Object
- #describe_failed_match(exception) ⇒ Object
-
#initialize ⇒ CodeErrorMatcher
constructor
A new instance of CodeErrorMatcher.
- #to_s ⇒ Object
-
#with_ruby_exception(matcher) ⇒ Object
Match the underlying ruby exception.
-
#without_ruby_exception ⇒ Object
Match a CodeError without an original exception.
Methods inherited from LocalizedErrorMatcher
#matches_task?, #to_execution_exception_matcher, #with_model, #with_origin, #with_original_exception
Methods included from DRoby::V5::Queries::LocalizedErrorMatcherDumper
Methods inherited from MatcherBase
#&, declare_class_methods, #each, #indexed_query?, #match, match_predicate, match_predicates, #negate, #|
Constructor Details
#initialize ⇒ CodeErrorMatcher
Returns a new instance of CodeErrorMatcher.
9 10 11 12 13 |
# File 'lib/roby/queries/code_error_matcher.rb', line 9 def initialize super @ruby_exception_class = ::Exception with_model(CodeError) end |
Instance Attribute Details
#ruby_exception_class ⇒ Object (readonly)
Returns the value of attribute ruby_exception_class.
8 9 10 |
# File 'lib/roby/queries/code_error_matcher.rb', line 8 def ruby_exception_class @ruby_exception_class end |
Instance Method Details
#===(error) ⇒ Object
30 31 32 33 |
# File 'lib/roby/queries/code_error_matcher.rb', line 30 def ===(error) return false if !super ruby_exception_class === error.error end |
#describe_failed_match(exception) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/roby/queries/code_error_matcher.rb', line 44 def describe_failed_match(exception) if description = super return description elsif !(ruby_exception_class === exception.error) if ruby_exception_class return "the underlying exception #{exception.error} does not match the expected #{ruby_exception_class}" else return "there is an underlying exception (#{exception.error}) but the matcher expected none" end end end |
#to_s ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/roby/queries/code_error_matcher.rb', line 35 def to_s description = super if ruby_exception_class description.concat(".with_ruby_exception(#{ruby_exception_class})") else description.concat(".without_ruby_exception") end end |
#with_ruby_exception(matcher) ⇒ Object
Match the underlying ruby exception
19 20 21 22 23 |
# File 'lib/roby/queries/code_error_matcher.rb', line 19 def with_ruby_exception(matcher) with_original_exception(matcher) @ruby_exception_class = matcher self end |
#without_ruby_exception ⇒ Object
Match a CodeError without an original exception
26 27 28 |
# File 'lib/roby/queries/code_error_matcher.rb', line 26 def without_ruby_exception with_ruby_exception(nil) end |