Sha256: 88aef105dd47a31d98bbea5fd091160b7795f98b74aadb3847fdc9b37a4ed46f

Contents?: true

Size: 714 Bytes

Versions: 7

Compression:

Stored size: 714 Bytes

Contents

require 'protobuf/rpc/rpc.pb'

module Protobuf
  module Rpc
    ClientError = Struct.new("ClientError", :code, :message)
    
    # Base PbError class for client and server errors
    class PbError < StandardError
      attr_reader :error_type
      
      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
      
      def to_response response
        response.error = message
        response.error_reason = @error_type
      end
    end
  end
end

require 'protobuf/rpc/error/server_error'
require 'protobuf/rpc/error/client_error'

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
protobuf-2.0.0.rc3 lib/protobuf/rpc/error.rb
protobuf-2.0.0.rc2 lib/protobuf/rpc/error.rb
protobuf-2.0.0.rc1 lib/protobuf/rpc/error.rb
protobuf-1.4.2 lib/protobuf/rpc/error.rb
protobuf-1.4.1 lib/protobuf/rpc/error.rb
protobuf-1.4.0 lib/protobuf/rpc/error.rb
protobuf-1.3.0 lib/protobuf/rpc/error.rb