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

#to_response(response) ⇒ Object



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

def to_response response
  response.error = message
  response.error_reason = @error_type
end