Exception: ModernTimes::RemoteException

Inherits:
Exception
  • Object
show all
Defined in:
lib/modern_times/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/modern_times/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/modern_times/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/modern_times/remote_exception.rb', line 3

def originating_exception_name
  @originating_exception_name
end

Class Method Details

.from_hash(hash) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/modern_times/remote_exception.rb', line 33

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

Instance Method Details

#messageObject



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

def message
  @message || @originating_exception_message
end

#message=(msg) ⇒ Object



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

def message=(msg)
  @message = msg
end

#to_hashObject



24
25
26
27
28
29
30
31
# File 'lib/modern_times/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