Skip to content

Commit

Permalink
adding specific rescues for http open and read timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
sgreen-r7 committed Aug 31, 2017
1 parent 33e09f0 commit 852c14a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/nexpose/api_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,13 @@ def execute(options = {})
$stderr.puts "\n\nRetrying the request due to #{error}. If you see this message please open an Issue on Github with the error.\n\n"
retry
end
### HTTP Specific Timeout Errors.
rescue ::Net::ReadTimeout, ::Net::OpenTimeout => error
timeout_value = error.instance_of?(Net::ReadTimeout) ? @http.read_timeout : @http.open_timeout
@error = "Nexpose did not respond within #{timeout_value} seconds #{error}. Reference the Wiki for information on setting the different Timeout values."
### Catch all Timeout Error.
rescue ::Timeout::Error => error
@error = "Nexpose did not respond within #{@http.read_timeout} seconds. Reference the Wiki for information on setting the different Timeout values."
@error = "Nexpose did not respond within #{@http.read_timeout} seconds #{error}. Reference the Wiki for information on setting the different Timeout values."
rescue ::Errno::EHOSTUNREACH, ::Errno::ENETDOWN, ::Errno::ENETUNREACH, ::Errno::ENETRESET, ::Errno::EHOSTDOWN, ::Errno::EACCES, ::Errno::EINVAL, ::Errno::EADDRNOTAVAIL
@error = 'Nexpose host is unreachable.'
# Handle console-level interrupts
Expand Down

0 comments on commit 852c14a

Please sign in to comment.