Exception: MessagePack::RPC::RPCError

Inherits:
Error
  • Object
show all
Defined in:
lib/msgpack/rpc/exception.rb,
lib/msgpack/rpc/exception.rb

Overview

MessagePack-RPC Exception

RPCError
|
+-- TimeoutError
|
+-- TransportError
|   |
|   +-- NetworkUnreachableError
|   |
|   +-- ConnectionRefusedError
|   |
|   +-- ConnectionTimeoutError
|   |
|   +-- MalformedMessageError
|   |
|   +-- StreamClosedError
|
+-- CallError
|   |
|   +-- NoMethodError
|   |
|   +-- ArgumentError
|
+-- ServerError
|   |
|   +-- ServerBusyError
|
+-- RemoteError
    |
    +-- RuntimeError
    |
    +-- (user-defined errors)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, *data) ⇒ RPCError

Returns a new instance of RPCError.



63
64
65
66
67
# File 'lib/msgpack/rpc/exception.rb', line 63

def initialize(code, *data)
  @code = code.to_s
  @data = data
  super(@data.shift || @code)
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



68
69
70
# File 'lib/msgpack/rpc/exception.rb', line 68

def code
  @code
end

#dataObject (readonly)

Returns the value of attribute data.



69
70
71
# File 'lib/msgpack/rpc/exception.rb', line 69

def data
  @data
end

Class Method Details

.create(code, data) ⇒ Object



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/msgpack/rpc/exception.rb', line 175

def self.create(code, data)
  if code[0] == ?.
    code = code.dup
    while true
      if klass = SYSTEM_ERROR_TABLE[code]
        return klass.new(*data)
      end
      if code.slice!(/\.[^\.]*$/) == nil || code.empty?
        return RPCError.new(code, *data)
      end
    end

  elsif code == RuntimeError::CODE
    RuntimeError.new(*data)

  else
    RemoteError.new(code, *data)
  end
end

Instance Method Details

#is?(code) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
74
75
76
77
78
79
# File 'lib/msgpack/rpc/exception.rb', line 71

def is?(code)
  if code.is_a?(Class) && code < RPCError
    if code == RemoteError
      return @code[0] != ?.
    end
    code = code::CODE
  end
  @code == code || @code[0,code.length+1] == "#{code}."
end