Skip to content
This repository has been archived by the owner on Aug 29, 2018. It is now read-only.

Commit

Permalink
[Bug 847685] seperate connection errors from timeouts
Browse files Browse the repository at this point in the history
Add a more descriptive error message for timeouts stating that the
operation may have finished even though there was a timeout
  • Loading branch information
John (J5) Palmieri committed Aug 20, 2012
1 parent 073c5b6 commit 262c565
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions lib/rhc-rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ def request(request)
@@headers["cookie"] = "rh_sso=#{rh_sso}"
end
return parse_response(response) unless response.nil? or response.code == 204
rescue RestClient::RequestTimeout, RestClient::ServerBrokeConnection => e
raise ConnectionException.new("Connection to server timed out or got interrupted: #{e.message}")
rescue RestClient::RequestTimeout => e
raise TimeoutException.new("Connection to server timed out. It is possible the operation finished without being able to report success. Use 'rhc domain show' or 'rhc app status' to check the status of your applications.")
rescue RestClient::ServerBrokeConnection => e
raise ConnectionException.new("Connection to server got interrupted: #{e.message}")
rescue RestClient::ExceptionWithResponse => e
process_error_response(e.response)
rescue Exception => e
Expand Down
2 changes: 1 addition & 1 deletion lib/rhc-rest/exceptions/exceptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,6 @@ class UnAuthorizedException < Rhc::Rest::ClientErrorException; end
class ResourceAccessException < Rhc::Rest::BaseException; end
#I/O Exceptions Connection timeouts, etc
class ConnectionException < Rhc::Rest::BaseException; end

class TimeoutException < ConnectionException; end
end
end
4 changes: 2 additions & 2 deletions spec/rhc/rest_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ module Rhc
:method => 'get',
:headers => {:accept => :json}
)
lambda { subject.request(request) }.should raise_error(Rhc::Rest::ConnectionException, 'Connection to server timed out or got interrupted: Request Timeout')
lambda { subject.request(request) }.should raise_error(Rhc::Rest::TimeoutException, "Connection to server timed out. It is possible the operation finished without being able to report success. Use 'rhc domain show' or 'rhc app status' to check the status of your applications.")
end
end

Expand All @@ -296,7 +296,7 @@ module Rhc
:method => 'get',
:headers => {:accept => :json}
)
lambda { subject.request(request) }.should raise_error(Rhc::Rest::ConnectionException, 'Connection to server timed out or got interrupted: Lost Server Connection')
lambda { subject.request(request) }.should raise_error(Rhc::Rest::ConnectionException, 'Connection to server got interrupted: Lost Server Connection')
end
end

Expand Down

0 comments on commit 262c565

Please sign in to comment.