Add BadStatus#to_rpc_status

pull/18752/head
Mike Moore 6 years ago
parent d418c42f1e
commit f370542dd6
No known key found for this signature in database
GPG Key ID: DD7A8E4072BD187A
  1. 16
      src/ruby/lib/grpc/errors.rb

@ -13,6 +13,7 @@
# limitations under the License.
require_relative './grpc'
require_relative './google_rpc_status_utils'
# GRPC contains the General RPC module.
module GRPC
@ -47,7 +48,20 @@ module GRPC
#
# @return [Status] with the same code and details
def to_status
Struct::Status.new(code, details, @metadata)
Struct::Status.new(code, details, metadata)
end
# Converts the exception to a deserialized Google::Rpc::Status proto.
# Returns nil if the `grpc-status-details-bin` trailer could not be
# converted to a {Google::Rpc::Status} due to the server not providing
# the necessary trailers.
#
# Raises an error if the server did provide the necessary trailers
# but they fail to deserialize into a {Google::Rpc::Status} protobuf.
#
# @return [Google::Rpc::Status] with the same code and details
def to_rpc_status
GoogleRpcStatusUtils.extract_google_rpc_status to_status
end
def self.new_status_exception(code, details = 'unknown cause',

Loading…
Cancel
Save