From 295dd54057f11ea52cdda5d402c1796cd657e7bc Mon Sep 17 00:00:00 2001 From: Hiro Asari Date: Wed, 10 Jun 2020 13:46:52 -0400 Subject: [PATCH] Wrap `rescue` in `begin; end` block For Ruby < 2.5 compatibility --- lib/travis/cli/api_command.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/travis/cli/api_command.rb b/lib/travis/cli/api_command.rb index 6c6da5bb..ff6e0045 100644 --- a/lib/travis/cli/api_command.rb +++ b/lib/travis/cli/api_command.rb @@ -34,13 +34,15 @@ class ApiCommand < Command on('--adapter ADAPTER', 'Faraday adapter to use for HTTP requests. If omitted, use Typhoeus if it is installed, ' \ 'and Net::HTTP otherwise. See https://lostisland.github.io/faraday/adapters/ for more info') do |c, adapter| - adapter.gsub! '-', '_' - require "faraday/adapter/#{adapter}" - require 'typhoeus/adapters/faraday' if adapter == 'typhoeus' - c.session.faraday_adapter = adapter.to_sym - rescue LoadError => e - warn "\`--adapter #{adapter}\` is given, but it is not installed. Run \`gem install #{adapter}\` and try again" - exit 1 + begin + adapter.gsub! '-', '_' + require "faraday/adapter/#{adapter}" + require 'typhoeus/adapters/faraday' if adapter == 'typhoeus' + c.session.faraday_adapter = adapter.to_sym + rescue LoadError => e + warn "\`--adapter #{adapter}\` is given, but it is not installed. Run \`gem install #{adapter}\` and try again" + exit 1 + end end def initialize(*)