Class: TwirpRails::ErrorHandling::Base::ErrorHandler

Inherits:
Struct
  • Object
show all
Defined in:
lib/twirp_rails/error_handling/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#codeObject

Returns the value of attribute code

Returns:

  • (Object)

    the current value of code



20
21
22
# File 'lib/twirp_rails/error_handling/base.rb', line 20

def code
  @code
end

#procObject

Returns the value of attribute proc

Returns:

  • (Object)

    the current value of proc



20
21
22
# File 'lib/twirp_rails/error_handling/base.rb', line 20

def proc
  @proc
end

Instance Method Details

#handle(error, client) ⇒ Object



25
26
27
# File 'lib/twirp_rails/error_handling/base.rb', line 25

def handle(error, client)
  proc.call(error, client)
end

#match?(error) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/twirp_rails/error_handling/base.rb', line 21

def match?(error)
  error.code == self.code
end

#process(error, client) ⇒ Object



29
30
31
# File 'lib/twirp_rails/error_handling/base.rb', line 29

def process(error, client)
  match?(error) ? handle(error, client) : nil
end