Method: Gruf::Controllers::Base#call

Defined in:
lib/gruf/controllers/base.rb

#call(method_key, &block) ⇒ Object

Call a method on this controller

Parameters:

  • method_key (Symbol)

    The name of the gRPC service method being called as a Symbol

  • &block (block)

    The passed block for executing the method



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/gruf/controllers/base.rb', line 89

def call(method_key, &block)
  Interceptors::Context.new(@interceptors).intercept! do
    process_action(method_key, &block)
  end
rescue GRPC::BadStatus
  raise # passthrough, to be caught by Gruf::Interceptors::Timer
rescue GRPC::Core::CallError, StandardError => e # CallError is not a StandardError
  set_debug_info(e.message, e.backtrace) if Gruf.backtrace_on_error
  error_message = Gruf.use_exception_message ? e.message : Gruf.internal_error_message
  fail!(:internal, :unknown, error_message)
end