Module: Gruf::Sentry::ErrorParser

Included in:
ClientInterceptor, ServerInterceptor
Defined in:
lib/gruf/sentry/error_parser.rb

Overview

Mixin for error parsing

Instance Method Summary collapse

Instance Method Details

#code_for(error) ⇒ Number

Returns that maps to one of the GRPC::Core::StatusCodes or Gruf::Sentry.default_error_code.

Parameters:

  • (StandardError)

Returns:

  • (Number)

    that maps to one of the GRPC::Core::StatusCodes or Gruf::Sentry.default_error_code



28
29
30
# File 'lib/gruf/sentry/error_parser.rb', line 28

def code_for(error)
  error.respond_to?(:code) ? error.code : Gruf::Sentry.default_error_code
end

#error?(exception) ⇒ Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/gruf/sentry/error_parser.rb', line 35

def error?(exception)
  error_classes.include?(exception.class.to_s)
end

#error_classesArray

Returns:

  • (Array)


42
43
44
# File 'lib/gruf/sentry/error_parser.rb', line 42

def error_classes
  @options.fetch(:error_classes, Gruf::Sentry.grpc_error_classes)
end