Class: Cucumber::Distrib::Events::Exception

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/distrib/events.rb

Overview

Object that mimic exception on the Leader for reporters.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exception, propagate_cause: true) ⇒ Exception

Returns a new instance of Exception.

Parameters:



128
129
130
131
132
133
134
135
136
137
138
# File 'lib/cucumber/distrib/events.rb', line 128

def initialize(exception, propagate_cause: true)
  @original_class = if exception.is_a?(Class)
                      exception.to_s
                    else
                      exception.class.to_s
                    end

  @backtrace = exception.backtrace
  @cause = Exception.new(exception.cause, propagate_cause: false) if exception.cause && propagate_cause
  @message = exception.message
end

Instance Attribute Details

#backtraceObject (readonly)

Returns the value of attribute backtrace.



125
126
127
# File 'lib/cucumber/distrib/events.rb', line 125

def backtrace
  @backtrace
end

#causeObject (readonly)

Returns the value of attribute cause.



125
126
127
# File 'lib/cucumber/distrib/events.rb', line 125

def cause
  @cause
end

#messageObject (readonly)

Returns the value of attribute message.



125
126
127
# File 'lib/cucumber/distrib/events.rb', line 125

def message
  @message
end

#original_classObject (readonly)

Returns the value of attribute original_class.



125
126
127
# File 'lib/cucumber/distrib/events.rb', line 125

def original_class
  @original_class
end

Instance Method Details

#classObject

This is used to present proper names for exceptions in cucumber reports.



146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/cucumber/distrib/events.rb', line 146

def class
  klass = original_class

  Class.new(::Cucumber::Distrib::Events::Exception).tap do |wrapper|
    wrapper.define_singleton_method :to_s do
      klass
    end

    wrapper.define_singleton_method :inspect do
      "Cucumber::Distrib::Events::Exception(#{self})"
    end
  end
end

#set_backtrace(backtrace) ⇒ Object

Parameters:

  • backtrace (Array<String>)


141
142
143
# File 'lib/cucumber/distrib/events.rb', line 141

def set_backtrace(backtrace) # rubocop:disable Naming/AccessorMethodName as on original interface
  @backtrace = backtrace
end