class ResponseError < Error
- Inherits from
Error
Raised when an HTTP response does not conform to gRPC. Preserves the buffered response for inspection.
Definitions
def self.for(response)
Create an error from an invalid response, buffering its body for inspection.
Signature
-
parameter
responseProtocol::HTTP::Response The invalid response.
-
returns
ResponseError The error with the buffered response attached.
Implementation
def self.for(response)
self.new("Invalid gRPC response: HTTP #{response.status}, content-type #{response.headers["content-type"].to_s.inspect}!", response.buffered!)
end
def initialize(message, response)
Initialize an error with a message and response.
Signature
-
parameter
messageString The reason the response is invalid.
-
parameter
responseProtocol::HTTP::Response The buffered response.
Implementation
def initialize(message, response)
super(message)
@response = response
end
attr :response
Signature
-
attribute
Protocol::HTTP::Response The buffered response, with its body available to read.