class Roby::Queries::CodeErrorMatcher
Matcher for CodeError
exceptions
In addition to the LocalizedError
properties, it allows to match properties on the Ruby exception that has been thrown
Attributes
ruby_exception_class[R]
Public Class Methods
new()
click to toggle source
Calls superclass method
Roby::Queries::LocalizedErrorMatcher::new
# File lib/roby/queries/code_error_matcher.rb, line 9 def initialize super @ruby_exception_class = ::Exception with_model(CodeError) end
Public Instance Methods
===(error)
click to toggle source
Calls superclass method
Roby::Queries::LocalizedErrorMatcher#===
# 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)
click to toggle source
Calls superclass method
Roby::Queries::LocalizedErrorMatcher#describe_failed_match
# 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()
click to toggle source
Calls superclass method
Roby::Queries::LocalizedErrorMatcher#to_s
# 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)
click to toggle source
Match the underlying ruby exception
@param [#===,Class] matcher an object that can match an Exception
object, usually an exception class
# 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()
click to toggle source
Match a CodeError
without an original exception
# File lib/roby/queries/code_error_matcher.rb, line 26 def without_ruby_exception with_ruby_exception(nil) end