Exception: Protobuf::Rpc::PbError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/protobuf/rpc/error.rb

Overview

Base PbError class for client and server errors

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = 'An unknown RpcError occurred', error_type = 'RPC_ERROR') ⇒ PbError

Returns a new instance of PbError.



11
12
13
14
# File 'lib/protobuf/rpc/error.rb', line 11

def initialize(message = 'An unknown RpcError occurred', error_type = 'RPC_ERROR')
  @error_type = error_type.is_a?(String) ? ::Protobuf::Socketrpc::ErrorReason.const_get(error_type) : error_type
  super message
end

Instance Attribute Details

#error_typeObject (readonly)

Returns the value of attribute error_type.



9
10
11
# File 'lib/protobuf/rpc/error.rb', line 9

def error_type
  @error_type
end

Instance Method Details

#encode(args = {}) ⇒ Object



16
17
18
# File 'lib/protobuf/rpc/error.rb', line 16

def encode(args = {})
  to_response(args).encode
end

#to_response(args = {}) ⇒ Object



20
21
22
# File 'lib/protobuf/rpc/error.rb', line 20

def to_response(args = {})
  ::Protobuf::Socketrpc::Response.new({ :error => message, :error_reason => error_type }.merge(args))
end