Exception handling strategy when using httparty #209

Closed
bsingr opened this Issue May 12, 2013 · 7 comments

Projects

None yet

9 participants

@bsingr
Contributor
bsingr commented May 12, 2013

Hey there!

I saw there are a few error classes defined in https://github.com/jnunemaker/httparty/blob/master/lib/httparty/exceptions.rb but there is no such thing as a global HTTParty::Error that allow a single rescue statement to catch up all possible errors when making requests with HTTParty. Instead I have to explicitely list all of the error classes defined by HTTParty.

Also I saw that these error classes are only used for special cases that occur within the HTTParty codebase and not for wrapping exceptions that occur in underlying libraries such as Net:HTTP.

Is there any reason for that I didn't see or would you appreciate me implementing a global error class and wrapping up exceptions from underlying libraries?

To clarify, I'd like to be able to do sth. like:

begin
  HTTParty.get('http://google.com')
rescue HTTParty::Error => e
  # handle e ...
end

Cheers
--dpree

@MikeAski
MikeAski commented Jul 2, 2013

👍

@pauldub
pauldub commented Nov 7, 2013

Yeah, that would be something nice to have! What's you opinion on this? Or maybe I should ask in which way do you handle errors?

@elangolab

+1

@bsingr bsingr added a commit to bsingr/httparty that referenced this issue Nov 28, 2013
@bsingr bsingr Add HTTParty::Error base class. Refs #209. 5621c87
@deepthawtz

Thanks for adding this in, very helpful.

I just noticed this is still not part of a gem release yet. Will that happen soon? I'd prefer to bundle from a specific version rather than from the git repo if possible.

@opyh
opyh commented Jan 15, 2014

+1

@tuxjobs
tuxjobs commented Mar 3, 2014

++

@ddevaal
ddevaal commented Mar 14, 2014

+1

@jnunemaker jnunemaker closed this Mar 14, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment