Sha256: fc6918fa6d57230c6d3243e896a31ea0f8fd1cdb6930eb83fe1ef5ed079ec31e

Contents?: true

Size: 1.2 KB

Versions: 24

Compression:

Stored size: 1.2 KB

Contents

module DeepTest
  class MarshallableExceptionWrapper
    attr_reader :classname, :message, :backtrace

    def initialize(exception)
      @classname = exception.class.name
      @message = exception.message
      @backtrace = exception.backtrace
    end

    def ==(other)
      classname == other.classname &&
        message == other.message &&
      backtrace == other.backtrace
    end

    def resolve
      begin
        klass = eval("::" + classname) 
        resolved_message = message
      rescue => e
        DeepTest.logger.debug("Unable to load exception class: #{classname}: #{e.message}")
        DeepTest.logger.debug(e.backtrace.join("\n"))

        klass = UnloadableException
        resolved_message = "#{classname}: #{message}"
      end

      begin
        resolved_exception = klass.new resolved_message
      rescue => e
        DeepTest.logger.debug("Unable to instantiation exception class: #{classname}: #{e.message}")
        DeepTest.logger.debug(e.backtrace.join("\n"))

        resolved_exception = UnloadableException.new resolved_message
      end

      resolved_exception.set_backtrace backtrace
      resolved_exception
    end
  end

  class UnloadableException < StandardError; end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
jason-o-matic-deep_test-1.2.2.1 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.10 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.11 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.12 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.13 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.14 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.2 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.3 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.4 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.5 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.6 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.7 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.8 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.9 lib/deep_test/marshallable_exception_wrapper.rb
jperkins-deep_test-1.2.2 lib/deep_test/marshallable_exception_wrapper.rb
jason-o-matic-deep_test-1.2.2.15 lib/deep_test/marshallable_exception_wrapper.rb
jstorimer-deep-test-1.4.0 lib/deep_test/marshallable_exception_wrapper.rb
jstorimer-deep-test-1.3.0 lib/deep_test/marshallable_exception_wrapper.rb
jstorimer-deep-test-1.2.0 lib/deep_test/marshallable_exception_wrapper.rb
jstorimer-deep-test-1.1.0 lib/deep_test/marshallable_exception_wrapper.rb