Exception: Qwirk::RemoteException

Inherits:
Exception
  • Object
show all
Defined in:
lib/qwirk/remote_exception.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(originating_exception = nil, message = nil) ⇒ RemoteException

Returns a new instance of RemoteException.



6
7
8
9
10
11
12
13
14
# File 'lib/qwirk/remote_exception.rb', line 6

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

Instance Attribute Details

#originating_exception_messageObject

Returns the value of attribute originating_exception_message.



4
5
6
# File 'lib/qwirk/remote_exception.rb', line 4

def originating_exception_message
  @originating_exception_message
end

#originating_exception_nameObject

Returns the value of attribute originating_exception_name.



3
4
5
# File 'lib/qwirk/remote_exception.rb', line 3

def originating_exception_name
  @originating_exception_name
end

Class Method Details

.from_hash(hash) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/qwirk/remote_exception.rb', line 37

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

.unmarshal(yaml_str) ⇒ Object



46
47
48
# File 'lib/qwirk/remote_exception.rb', line 46

def self.unmarshal(yaml_str)
  from_hash(YAML.load(yaml_str))
end

Instance Method Details

#marshalObject



33
34
35
# File 'lib/qwirk/remote_exception.rb', line 33

def marshal
  to_hash.to_yaml
end

#messageObject



16
17
18
# File 'lib/qwirk/remote_exception.rb', line 16

def message
  @message || @originating_exception_message
end

#message=(msg) ⇒ Object



20
21
22
# File 'lib/qwirk/remote_exception.rb', line 20

def message=(msg)
  @message = msg
end

#to_hashObject



24
25
26
27
28
29
30
31
# File 'lib/qwirk/remote_exception.rb', line 24

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