Sha256: 3d077136926f8c677853f83a1a484c1f67a38f59bd9357f5a93765b218fb092e

Contents?: true

Size: 736 Bytes

Versions: 24

Compression:

Stored size: 736 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) ? Socketrpc::ErrorReason.const_get(error_type) : error_type
        super message
      end

      def encode
        to_response.encode
      end

      def to_response
        Socketrpc::Response.new(:error => message, :error_reason => error_type)
      end
    end
  end
end

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

Version data entries

24 entries across 24 versions & 2 rubygems

Version Path
protobuf-3.0.1 lib/protobuf/rpc/error.rb
protobuf-3.0.0 lib/protobuf/rpc/error.rb
protobuf-3.0.0.rc2 lib/protobuf/rpc/error.rb
protobuf-3.0.0.rc1 lib/protobuf/rpc/error.rb