Skip to content

Commit

Permalink
Wrap rescue in begin; end block
Browse files Browse the repository at this point in the history
For Ruby < 2.5 compatibility
  • Loading branch information
BanzaiMan committed Jun 15, 2020
1 parent aaa20e7 commit 295dd54
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/travis/cli/api_command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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(*)
Expand Down

0 comments on commit 295dd54

Please sign in to comment.