-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Graphlient::Errors::ConnectionFailedError #68
Add Graphlient::Errors::ConnectionFailedError #68
Conversation
This is essentially #59 with test. Whenever there is an `Errno::ECONNREFUSED error`, Faraday wraps it in a `Faraday::ConnectionFailed` error. Since it inherits `Faraday::ClientError` without a response (see errors/faraday_server_error.rb), the code would return a `NoMethodError: undefined method []' for nil:NilClass` error. So basically the fix is to rescue `Faraday::ConnectionFailed` before rescuing `Faraday::ClientError` so that we can raise a more meaningful error. Result: ``` Graphlient::Errors::ConnectionFailedError: Failed to open TCP connection to localhost:3000 (Connection refused - connect(2) for "localhost" port 3000) ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm good with this pending the minor changelog entry comment.
stub_request(:post, url).to_raise(error) | ||
end | ||
|
||
specify do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy :)
Oh one thing. You should add an UPGRADING document in this PR like this one because this does change the interface. If someone was handling the Faraday error they now get a ServerError. |
@dblock, I've updated CHANGELOG.md and README.md. Also added UPGRADING.md. Question though, do you want a new section in README.md like https://github.com/dblock/slack-ruby-client#stable-release? |
This is perfect, thank you. Feel free to PR something linking to UPGRADING. |
thanks @neroleung ! this is awesome! going to cut the release, hopefully before @dblock 😄 |
alright |
This is essentially #59 with test.
Whenever there is an
Errno::ECONNREFUSED error
, Faraday wraps it in aFaraday::ConnectionFailed
error. Since it inheritsFaraday::ClientError
without a response (see errors/faraday_server_error.rb), the code would return aNoMethodError: undefined method []' for nil:NilClass
error.So basically the fix is to rescue
Faraday::ConnectionFailed
before rescuingFaraday::ClientError
so that we can raise a more meaningful error.Result: