Exception: GRPC::BadStatus

Inherits:
StandardError
  • Object
show all
Defined in:
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', **kw) ⇒ BadStatus

Returns a new instance of BadStatus.

Parameters:

  • code (Numeric)

    the status code

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

    the details of the exception



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

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

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



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

def code
  @code
end

#detailsObject (readonly)

Returns the value of attribute details.



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

def details
  @details
end

#metadataObject (readonly)

Returns the value of attribute metadata.



39
40
41
# File '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



54
55
56
# File 'lib/grpc/errors.rb', line 54

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