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

Consider more appropriate error classes for networking or gateway failures #207

Open
jasonwebster opened this issue Jul 25, 2016 · 0 comments

Comments

@jasonwebster
Copy link

One specific example that I ran into recently was dealing with bunk responses from Paypal when verifying an IPN signature. The code in

raise StandardError.new("Faulty paypal result: #{response}") unless ["VERIFIED", "INVALID"].include?(response)
simply raises a StandardError, which makes it somewhat fragile to trap and deal with appropriately, as I had to rely on message substring matching to catch that specific one. However, this issue is wider spread than just the Paypal integration, as many of them raise StandardErrors for either malformed responses, networking failures or even input validation (where ArgumentError would be more appropriate).

Aside from some obvious places where we should raise ArgumentError instead of StandardError (

raise StandardError, "Integration mode set to an invalid value: #{mode}"
for example), one option would be a base IntegrationError < StandardError, which we could subclass within each integration's namespace and be able to rescue specifically from as necessary. However, there might be some benefit in being able to distinguish between logic errors and network failures.

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

1 participant