Skip to content

Commit

Permalink
Merge pull request #110 from treasure-data/http-errors
Browse files Browse the repository at this point in the history
Organize HTTP exceptions
  • Loading branch information
nurse committed Jul 11, 2017
2 parents 7dc0733 + 8ad4b3b commit be7ad91
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/td/client/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,9 @@ def do_get(url, params=nil, &block)
retry_delay *= 2
redo # restart from beginning of do-while loop
end
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Timeout::Error, EOFError, OpenSSL::SSL::SSLError, SocketError, IncompleteError, HTTPClient::TimeoutError => e
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Timeout::Error, EOFError,
SystemCallError, OpenSSL::SSL::SSLError, SocketError, HTTPClient::TimeoutError,
IncompleteError => e
if block_given?
raise e
end
Expand Down
3 changes: 2 additions & 1 deletion lib/td/client/api/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,8 @@ def job_result_download(job_id, format='msgpack', autodecode=true)
# completed?
validate_content_length_with_range(response, current_total_chunk_size)
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Timeout::Error, EOFError,
OpenSSL::SSL::SSLError, SocketError, HTTPServerException => e
SystemCallError, OpenSSL::SSL::SSLError, SocketError, HTTPClient::TimeoutError,
HTTPServerException => e
if response # at least a chunk is downloaded
if etag = response.header['ETag'][0]
header['If-Range'] = etag
Expand Down
3 changes: 2 additions & 1 deletion lib/td/client/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,8 @@ def wait(*args)
yield self if block_given?
rescue timeout_klass
raise Timeout::Error, $!.message
rescue Timeout::Error, SystemCallError, EOFError, SocketError, HTTPClient::ConnectTimeoutError
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, Timeout::Error, EOFError,
SystemCallError, OpenSSL::SSL::SSLError, SocketError, HTTPClient::TimeoutError
$stderr.puts "ignore network error (#{$!}); retry..." if verbose
end until finished?
end
Expand Down

0 comments on commit be7ad91

Please sign in to comment.