Skip to content
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

Exception handling strategy when using httparty #209

Closed
bsingr opened this issue May 12, 2013 · 8 comments
Closed

Exception handling strategy when using httparty #209

bsingr opened this issue May 12, 2013 · 8 comments

Comments

@bsingr
Copy link
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
Copy link

MikeAski commented Jul 2, 2013

👍

@pauldub
Copy link

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
Copy link

+1

bsingr added a commit to bsingr/httparty that referenced this issue Nov 28, 2013
jnunemaker pushed a commit that referenced this issue Nov 30, 2013
Add HTTParty::Error base class. Refs #209.
@deepthawtz
Copy link

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
Copy link

opyh commented Jan 15, 2014

+1

@tuxjobs
Copy link

tuxjobs commented Mar 3, 2014

++

@ghost
Copy link

ghost commented Mar 14, 2014

+1

@alanPaivaAsp
Copy link

This is not rescuing at all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants