Exception: GRPC::BadStatus

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

Overview

BadStatus is an exception class that indicates that an error occurred at either end of a GRPC connection. When raised, it indicates that a status error should be returned to the other end of a GRPC connection; when caught it means that this end received a status error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, details = 'unknown cause', metadata = {}) ⇒ BadStatus

Returns a new instance of BadStatus.

Parameters:

  • code (Numeric)

    the status code

  • details (String) (defaults to: 'unknown cause')

    the details of the exception

  • metadata (Hash) (defaults to: {})

    the error’s metadata



44
45
46
47
48
49
# File 'src/ruby/lib/grpc/errors.rb', line 44

def initialize(code, details = 'unknown cause',  = {})
  super("#{code}:#{details}")
  @code = code
  @details = details
  @metadata = 
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



39
40
41
# File 'src/ruby/lib/grpc/errors.rb', line 39

def code
  @code
end

#detailsObject (readonly)

Returns the value of attribute details.



39
40
41
# File 'src/ruby/lib/grpc/errors.rb', line 39

def details
  @details
end

#metadataObject (readonly)

Returns the value of attribute metadata.



39
40
41
# File 'src/ruby/lib/grpc/errors.rb', line 39

def 
  @metadata
end

Instance Method Details

#to_statusStatus

Converts the exception to a GRPC::Status for use in the networking wrapper layer.

Returns:

  • (Status)

    with the same code and details



55
56
57
# File 'src/ruby/lib/grpc/errors.rb', line 55

def to_status
  Struct::Status.new(code, details, @metadata)
end