HTTPErrors are more cryptic than we intend
Closed this issue · 0 comments
yzl commented
We are trying to provide user-friendly error messages for HTTPError in errors.rb, but they are being lost, e.g.
require 'artifactory'
Artifactory.configure do |config|
config.endpoint = 'http://localhost:8081/artifactory/nosuchendpoint'
config.username = 'admin'
config.password = 'password'
end
gives this error
sealam01:artifactory-client yvonnelam$ bundle exec ruby thing2.rb
/Users/yvonnelam/src/artifactory-client/lib/artifactory/client.rb:341:in `error': Artifactory::Error::HTTPError
from /Users/yvonnelam/src/artifactory-client/lib/artifactory/client.rb:227:in `block in request'
from /Users/yvonnelam/.rbenv/versions/1.9.3-p448/lib/ruby/1.9.1/net/http.rb:746:in `start'
from /Users/yvonnelam/src/artifactory-client/lib/artifactory/client.rb:217:in `request'
from /Users/yvonnelam/src/artifactory-client/lib/artifactory/client.rb:80:in `get'
from /Users/yvonnelam/src/artifactory-client/lib/artifactory/resources/system.rb:68:in `configuration'
from thing2.rb:9:in `<main>'
Oddly, we do get the user-friendly errors for ConnectionError, e.g.
require 'artifactory'
Artifactory.configure do |config|
config.endpoint = 'http://nowhere:8081/artifactory'
config.username = 'admin'
config.password = 'password'
end
does produce output with a nice error message as well as the exception:
sealam01:artifactory-client yvonnelam$ bundle exec ruby thing1.rb
/Users/yvonnelam/src/artifactory-client/lib/artifactory/client.rb:231:in `rescue in request': The Artifactory server at `http://nowhere:8081/artifactory' is not currently accepting connections. Please ensure that the server is running an that your authentication information is correct. (Artifactory::Error::ConnectionError)
from /Users/yvonnelam/src/artifactory-client/lib/artifactory/client.rb:163:in `request'
from /Users/yvonnelam/src/artifactory-client/lib/artifactory/client.rb:80:in `get'
from /Users/yvonnelam/src/artifactory-client/lib/artifactory/resources/system.rb:68:in `configuration'
from thing1.rb:9:in `<main>'