Class: Upfluence::Utils::Thrift::Middleware::ErrorCatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/upfluence/utils/thrift/middleware/error_catcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, error_logger) ⇒ ErrorCatcher

Returns a new instance of ErrorCatcher.



6
7
8
9
# File 'lib/upfluence/utils/thrift/middleware/error_catcher.rb', line 6

def initialize(app, error_logger)
  @app = app
  @error_logger = error_logger
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/upfluence/utils/thrift/middleware/error_catcher.rb', line 11

def method_missing(method, *args, &block)
  @app.send(method, *args, &block)
rescue ::Thrift::Exception => e
  raise e
rescue => e
  @error_logger.notify(e, method, *args)

  raise ::Thrift::ApplicationException.new(
    ::Thrift::ApplicationException::INTERNAL_ERROR,
    e.to_s
  )
end