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.6.12 lib/protobuf/rpc/error.rb
protobuf-3.6.11 lib/protobuf/rpc/error.rb
protobuf-3.6.10 lib/protobuf/rpc/error.rb
protobuf-3.7.0.pre2 lib/protobuf/rpc/error.rb
protobuf-3.6.9 lib/protobuf/rpc/error.rb
protobuf-3.7.0.pre1 lib/protobuf/rpc/error.rb
protobuf-3.7.0.pre0 lib/protobuf/rpc/error.rb
protobuf-3.6.7 lib/protobuf/rpc/error.rb
protobuf-3.6.6 lib/protobuf/rpc/error.rb
protobuf-3.6.2 lib/protobuf/rpc/error.rb
protobuf-3.6.1 lib/protobuf/rpc/error.rb
protobuf-3.6.0 lib/protobuf/rpc/error.rb
protobuf-3.5.5 lib/protobuf/rpc/error.rb
protobuf-3.5.4 lib/protobuf/rpc/error.rb
protobuf-3.5.3 lib/protobuf/rpc/error.rb
protobuf-3.5.2 lib/protobuf/rpc/error.rb
protobuf-3.5.1 lib/protobuf/rpc/error.rb
prepor-protobuf-3.5.1 lib/protobuf/rpc/error.rb
prepor-protobuf-3.5.0 lib/protobuf/rpc/error.rb
protobuf-3.5.0 lib/protobuf/rpc/error.rb