Sha256: 01e1dd64bffbb94a5e75cb2915f0ae97ca70bdb2419d876e41ecff9540a656a9

Contents?: true

Size: 485 Bytes

Versions: 7

Compression:

Stored size: 485 Bytes

Contents

require 'faraday'

module TranslationEngine
  class ConnectionExceptionMiddleware < Faraday::Middleware
    def call(env)
      begin
        @app.call(env)
      rescue Faraday::Error => e
        message = "Connecting to TranslationServer got #{e.class}: #{e.message}"

        if TranslationEngine.raise_exceptions
          raise TranslationEngine::ConnectionError, message
        else
          Rails.logger.error { message }
          {}
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
translation_engine-0.2.0 app/middlewares/translation_engine/connection_exception_middleware.rb
translation_engine-0.1.0 app/middlewares/translation_engine/connection_exception_middleware.rb
translation_engine-0.0.8 app/middlewares/translation_engine/connection_exception_middleware.rb
translation_engine-0.0.7 app/middlewares/translation_engine/connection_exception_middleware.rb
translation_engine-0.0.5 app/middlewares/translation_engine/connection_exception_middleware.rb
translation_engine-0.0.4 app/middlewares/translation_engine/connection_exception_middleware.rb
translation_engine-0.0.3 app/middlewares/translation_engine/connection_exception_middleware.rb