Allow BadStatus to contain metadata

pull/1309/head
Tim Emiola 10 years ago
parent 3fd2be2e32
commit 1c5faea673
  1. 7
      src/ruby/lib/grpc/errors.rb

@ -36,14 +36,15 @@ module GRPC
# error should be returned to the other end of a GRPC connection; when
# caught it means that this end received a status error.
class BadStatus < StandardError
attr_reader :code, :details
attr_reader :code, :details, :metadata
# @param code [Numeric] the status code
# @param details [String] the details of the exception
def initialize(code, details = 'unknown cause')
def initialize(code, details = 'unknown cause', **kw)
super("#{code}:#{details}")
@code = code
@details = details
@metadata = kw
end
# Converts the exception to a GRPC::Status for use in the networking
@ -51,7 +52,7 @@ module GRPC
#
# @return [Status] with the same code and details
def to_status
Status.new(code, details)
Struct::Status.new(code, details, @metadata)
end
end

Loading…
Cancel
Save