Skip to content

Make 'code' method configurable #23

@SirRawlins

Description

@SirRawlins

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions