api: improve exception handling.
This commit is contained in:
parent
cbda171c2b
commit
9ba6aef820
@ -45,15 +45,16 @@ module Homebrew
|
||||
curl_args.prepend("--time-cond", target) if target.exist? && !target.empty?
|
||||
|
||||
begin
|
||||
# Disable retries here, we handle them ourselves below.
|
||||
Utils::Curl.curl_download(*curl_args, to: target, max_time: JSON_API_MAX_TIME, retries: 0)
|
||||
begin
|
||||
# Disable retries here, we handle them ourselves below.
|
||||
Utils::Curl.curl_download(*curl_args, to: target, max_time: JSON_API_MAX_TIME, retries: 0)
|
||||
rescue ErrorDuringExecution
|
||||
raise unless target.exist?
|
||||
raise if target.empty?
|
||||
|
||||
JSON.parse(target.read)
|
||||
rescue ErrorDuringExecution
|
||||
raise unless target.exist?
|
||||
raise if target.empty?
|
||||
opoo "#{target.basename}: update failed, falling back to cached version."
|
||||
end
|
||||
|
||||
opoo "#{target.basename}: update failed, falling back to cached version."
|
||||
JSON.parse(target.read)
|
||||
rescue JSON::ParserError
|
||||
target.unlink
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user