Module: Gruf::Errors::Helpers

Included in:
Controllers::Base, Interceptors::ServerInterceptor
Defined in:
lib/gruf/errors/helpers.rb

Overview

Helper module for standardizing error interaction

Instance Method Summary collapse

Instance Method Details

#fail!(error_code, app_code = nil, message = '', metadata = {}) ⇒ Object

Will issue a GRPC BadStatus exception, with a code based on the code passed.

Parameters:

  • error_code (Symbol)

    The network error code that maps to gRPC status codes

  • app_code (Symbol) (defaults to: nil)

    The application-specific code for the error

  • message (String) (defaults to: '')

    (Optional) A detail message about the error

  • metadata (Hash) (defaults to: {})

    (Optional) Any metadata to inject into the trailing metadata for the response



34
35
36
37
38
39
40
41
# File 'lib/gruf/errors/helpers.rb', line 34

def fail!(error_code, app_code = nil, message = '',  = {})
  e = error
  e.code = error_code.to_sym
  e.app_code = app_code ? app_code.to_sym : e.code
  e.message = message.to_s
  e. = 
  e.fail!(request.active_call)
end