Module: ProtoPharm::StubComponents::FailureResponse

Included in:
ActionStub
Defined in:
lib/proto_pharm/stub_components/failure_response.rb

Instance Method Summary collapse

Instance Method Details

#to_failObject



13
14
15
# File 'lib/proto_pharm/stub_components/failure_response.rb', line 13

def to_fail
  to_fail_with
end

#to_fail_with(code = :invalid_argument, message = "unknown cause", **metadata) ⇒ Object

Parameters:

  • code (String, Symbol) (defaults to: :invalid_argument)

    A gRPC failure code, such as not_found or invalid_argument. Default: :invalid_argument

  • message (String) (defaults to: "unknown cause")

    A message to pass back with the exception

  • metadata (Hash)

    A hash of metadata to be passed back with the exception. See MetadataSerializers::Base.serialize.



9
10
11
# File 'lib/proto_pharm/stub_components/failure_response.rb', line 9

def to_fail_with(code = :invalid_argument, message = "unknown cause", **)
  to_raise(exception_class(code).new(message, .serialize(code: code, message: message, **)))
end