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

Make 'code' method configurable #23

Open
SirRawlins opened this issue Dec 9, 2019 · 1 comment
Open

Make 'code' method configurable #23

SirRawlins opened this issue Dec 9, 2019 · 1 comment

Comments

@SirRawlins
Copy link

A great looking gem. 👍

I was hoping to use wrap_and_check around some sendgrid-ruby requests, which return non-2XX response codes rather than raising exceptions. However the SendGrid::Response object exposes its status code through status_code() rather than code().

I can monkey-patch sendgrid-ruby to provide the code() method, but I wonder if this might be a nice configuration option for http-exceptions instead - maybe something like:

Http::Exceptions.configure do |config|
    config.status_code_method = :status_code
end

Or, perhaps an option to wrap_and_check would be even better?

response = Http::Exceptions.wrap_and_check(status_code_method: :status_code) do
    client.mail._('send').post(request_body: message.to_json)
end

If you think this might be useful, I'd be happy to wrap up a PR for it.

@marvin-rfbot
Copy link

marvin-rfbot bot commented Dec 9, 2019

Thanks for opening this issue!

@SirRawlins SirRawlins changed the title Made 'code' method configurable Make 'code' method configurable Dec 10, 2019
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