Sha256: d59821d4a3b2acef7fa0d5cec86649ed3056a6d1f67cc51361160a432582fce2

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

class ProconBypassMan::DeviceConnection::Command
  MAX_RETRY_COUNT = 3

  # @return [void]
  def self.execute!(retry_count: 0)
    begin
      gadget, procon = ProconBypassMan::DeviceConnection::Executer.execute!
    rescue ProconBypassMan::DeviceConnection::TimeoutErrorInConditionalRoute, ProconBypassMan::SafeTimeout::Timeout
      if retry_count >= MAX_RETRY_COUNT
        ProconBypassMan::SendErrorCommand.execute(error: "リトライしましたが、接続できませんでした")
        raise ProconBypassMan::DeviceConnection::TimeoutError
      else
        ProconBypassMan::SendErrorCommand.execute(error: "接続に失敗したのでリトライします")
      end

      retry_count = retry_count + 1
      retry
    rescue ProconBypassMan::DeviceConnection::NotFoundProconError, ProconBypassMan::DeviceConnection::SetupIncompleteError => e
      raise
    end

    ProconBypassMan::DeviceConnection::PreBypass.new(gadget: gadget, procon: procon).execute!
    ProconBypassMan::DeviceConnection::ProconSettingOverrider.new(procon: procon).execute!
    return [gadget, procon]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.12 lib/procon_bypass_man/device_connection/command.rb