Sha256: 6a08c70a93001f31e8f4d1d0b2686b2d2e64245c7c4ce94cdca400ad5168590c

Contents?: true

Size: 445 Bytes

Versions: 1

Compression:

Stored size: 445 Bytes

Contents

require 'faraday'

class TranslationEngine::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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
translation_engine-0.0.2 app/middlewares/translation_engine/connection_exception_middleware.rb