Skip to content

Commit a56e1dd

Browse files
committed
handle no-internet gracefully concerto#1413
1 parent acd9084 commit a56e1dd

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

app/models/concerto_plugin.rb

+9-5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@ class ConcertoPlugin < ActiveRecord::Base
2020

2121
def self.concerto_addons
2222
addons = Array.new
23-
#we shouldn't be checking github if it's just a script launching rails
24-
if !defined?(Rails::Console) && File.split($0).last != 'rake' && Octokit.rate_limit.remaining > 1
25-
repositories = Octokit.repos 'concerto-addons'
26-
repositories.each do |r|
27-
addons << [r.name.titleize, r.name]
23+
begin
24+
#we shouldn't be checking github if it's just a script launching rails
25+
if !defined?(Rails::Console) && File.split($0).last != 'rake' && Octokit.rate_limit.remaining > 1
26+
repositories = Octokit.repos 'concerto-addons'
27+
repositories.each do |r|
28+
addons << [r.name.titleize, r.name]
29+
end
2830
end
31+
rescue Faraday::ConnectionFailed => e
32+
Rails.logger.error("concerto-addons repos could not be enumerated - #{e.message}")
2933
end
3034
return addons
3135
end

lib/version_check.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ def self.latest_version
1010
end
1111
else # Fetch the latest version.
1212
Rails.logger.info 'Downloading latest Concerto version information for the first time.'
13-
version = Octokit.latest_release('concerto/concerto').tag_name
13+
begin
14+
version = Octokit.latest_release('concerto/concerto').tag_name
15+
rescue Faraday::ConnectionFailed => e
16+
Rails.logger.error "Unable to fetch Concerto version - #{e.message}"
17+
version = nil
18+
end
1419
end
1520
return version
1621
rescue Octokit::TooManyRequests => e

0 commit comments

Comments
 (0)