Sha256: 28cddd5a298f9fd45fcb1b47b0c9dab4084b7f0ab6f057eed6163dcd8820242d

Contents?: true

Size: 1.24 KB

Versions: 22

Compression:

Stored size: 1.24 KB

Contents

module ModernTimes
  class RemoteException < Exception
    attr_accessor :originating_exception_name
    attr_accessor :originating_exception_message

    def initialize(originating_exception=nil, message=nil)
      super(message)
      if originating_exception
        @originating_exception_name = originating_exception.class.name
        @originating_exception_message = originating_exception.message
        set_backtrace(originating_exception.backtrace)
      end
      @message = message
    end

    def message
      @message || @originating_exception_message
    end

    def message=(msg)
      @message = msg
    end

    def to_hash
      {
          'message'                       => @message,
          'originating_exception_name'    => @originating_exception_name,
          'originating_exception_message' => @originating_exception_message,
          'backtrace'                     => backtrace
      }
    end

    def self.from_hash(hash)
      exc = new
      exc.message                       = hash['message']
      exc.originating_exception_name    = hash['originating_exception_name']
      exc.originating_exception_message = hash['originating_exception_message']
      exc.set_backtrace(hash['backtrace'])
      return exc
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
modern_times-0.3.12 lib/modern_times/remote_exception.rb
modern_times-0.3.11 lib/modern_times/remote_exception.rb
modern_times-0.3.10 lib/modern_times/remote_exception.rb
modern_times-0.3.9 lib/modern_times/remote_exception.rb
modern_times-0.3.8 lib/modern_times/remote_exception.rb
modern_times-0.3.7 lib/modern_times/remote_exception.rb
modern_times-0.3.6 lib/modern_times/remote_exception.rb
modern_times-0.3.5 lib/modern_times/remote_exception.rb
modern_times-0.3.4 lib/modern_times/remote_exception.rb
modern_times-0.3.3 lib/modern_times/remote_exception.rb
modern_times-0.3.2 lib/modern_times/remote_exception.rb
modern_times-0.3.1 lib/modern_times/remote_exception.rb
modern_times-0.3.0 lib/modern_times/remote_exception.rb
modern_times-0.2.11 lib/modern_times/remote_exception.rb
modern_times-0.2.10 lib/modern_times/remote_exception.rb
modern_times-0.2.9 lib/modern_times/remote_exception.rb
modern_times-0.2.8 lib/modern_times/remote_exception.rb
modern_times-0.2.7 lib/modern_times/remote_exception.rb
modern_times-0.2.6 lib/modern_times/remote_exception.rb
modern_times-0.2.5 lib/modern_times/remote_exception.rb