Ask A Question

Notifications

You’re not receiving notifications from this thread.

Net Http API Client from Scratch Discussion

Super cool episode and the cat is amazing

Reply

This is a great summary and takes some of the scare away I had regarding Net::HTTP. However one of the reasons I always went with Faraday was the error handling. Net::HTTP seems to have all kinds of different exceptions I do not really care about. Maybe you can include the error handling into one of the upcoming episodes.

Reply

Errors are definitely a bit of a pain. I liked this approach from StackOverflow: https://stackoverflow.com/questions/5370697/what-s-the-best-way-to-handle-exceptions-from-nethttp

ALL_NET_HTTP_ERRORS = [
  Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
  Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError
]

begin
  your_http_logic()
rescue *ALL_NET_HTTP_ERRORS
  …
end
Reply

Thx u, Chris

Reply

Hey Chris, are we able to access the older version of this episode?

Reply

The old episodes are still there. This is just a new series digging deeper into designing API clients. 👍

Reply

Cat is a superstar. There's something about interruptions that makes things more funny and authentic. So if this basically the first step before extracting this to a ruby gem to build an sdk/wrapper? I'm going to watch that course next.

Reply

Looks like Ruby-Doc says that Rack::Utils.build_query is deprecated. Anything specific I should be using instead?
I was thinking URI.encode_www_form.

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,796+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.