Async::GRPCSourceAsyncGRPCRemoteError

class RemoteError

Represents an error that originated from a remote gRPC server. Used as the cause of Protocol::GRPC::Error when the client receives a non-OK status. The message and optional backtrace are extracted from response metadata.

Definitions

def self.for(message, metadata)

Create a RemoteError from server response metadata.

Signature

parameter message String | Nil

The error message from grpc-message header.

parameter metadata Hash

Response metadata (extracted from gRPC headers). If it contains a "backtrace" key (array of strings), it is set on the error and removed from the hash.

returns RemoteError

The constructed error instance.

Implementation

def self.for(message, metadata)
	self.new(message).tap do |error|
		if backtrace = metadata.delete("backtrace")
			# Backtrace is always an array (Split header format):
			error.set_backtrace(backtrace)
		end
	end
end