Class: GRPC::GoogleRpcStatusUtils

Inherits:
Object
  • Object
show all
Defined in:
src/ruby/lib/grpc/google_rpc_status_utils.rb

Overview

GoogleRpcStatusUtils provides utilities to convert between a GRPC::Core::Status and a deserialized Google::Rpc::Status proto Returns nil if the grpc-status-details-bin trailer could not be converted to a GoogleRpcStatus due to the server not providing the necessary trailers. Raises an error if the server did provide the necessary trailers but they fail to deseriliaze into a GoogleRpcStatus protobuf.

Class Method Summary collapse

Class Method Details

.extract_google_rpc_status(status) ⇒ Object



28
29
30
31
32
33
34
# File 'src/ruby/lib/grpc/google_rpc_status_utils.rb', line 28

def self.extract_google_rpc_status(status)
  fail ArgumentError, 'bad type' unless status.is_a? Struct::Status
  grpc_status_details_bin_trailer = 'grpc-status-details-bin'
  return nil if status.[grpc_status_details_bin_trailer].nil?
  Google::Rpc::Status.decode(
    status.[grpc_status_details_bin_trailer])
end