File: exception.rb

package info (click to toggle)
ruby-cucumber-wire 8.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 140 kB
  • sloc: ruby: 499; makefile: 4
file content (37 lines) | stat: -rw-r--r-- 917 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# frozen_string_literal: true

module Cucumber
  module Wire
    # Proxy for an exception that occurred at the remote end of the wire
    class Exception < StandardError
      module CanSetName
        attr_writer :exception_name

        def to_s
          @exception_name
        end
      end

      def initialize(args, config)
        super(args['message'])

        if args['exception']
          self.class.extend(CanSetName)
          self.class.exception_name = "#{args['exception']} from #{config}"
        end

        return unless args['backtrace']

        @backtrace = if args['backtrace'].is_a?(String)
                       args['backtrace'].split("\n") # TODO: change cuke4nuke to pass an array instead of a big string
                     else
                       args['backtrace']
                     end
      end

      def backtrace
        @backtrace || super
      end
    end
  end
end