Sha256: bd9c9f181e16c191e76279d2e2265854e2a1c9ec79795dc428e40396239e9706

Contents?: true

Size: 740 Bytes

Versions: 25

Compression:

Stored size: 740 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

25 entries across 25 versions & 2 rubygems

Version Path
protobuf-3.4.4 lib/protobuf/rpc/error.rb
protobuf-3.4.3 lib/protobuf/rpc/error.rb
protobuf-3.4.2 lib/protobuf/rpc/error.rb
protobuf-3.4.1 lib/protobuf/rpc/error.rb
protobuf-3.4.0 lib/protobuf/rpc/error.rb