Skip to content

Commit

Permalink
Make CardError's code parameter named instead of positional
Browse files Browse the repository at this point in the history
Makes the `code` parameter on `CardError` named instead of positional.
This makes it more consistent with the rest of the constructor's
parameters and makes instantiating `CardError` from `StripeClient`
cleaner.

This is a minor breaking change so we're aiming to release it for the
next major version of stripe-ruby.
  • Loading branch information
brandur committed Jul 29, 2019
1 parent 2c80bc8 commit ccdfe27
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
3 changes: 1 addition & 2 deletions lib/stripe/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ class APIError < StripeError
class CardError < StripeError
attr_reader :param

# TODO: make code a keyword arg in next major release
def initialize(message, param, code, http_status: nil, http_body: nil,
def initialize(message, param, code: nil, http_status: nil, http_body: nil,
json_body: nil, http_headers: nil)
super(message, http_status: http_status, http_body: http_body,
json_body: json_body, http_headers: http_headers,
Expand Down
5 changes: 1 addition & 4 deletions lib/stripe/stripe_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,8 @@ def execute_request(method, path,
when 401
AuthenticationError.new(error_data[:message], opts)
when 402
# TODO: modify CardError constructor to make code a keyword argument
# so we don't have to delete it from opts
opts.delete(:code)
CardError.new(
error_data[:message], error_data[:param], error_data[:code],
error_data[:message], error_data[:param],
opts
)
when 403
Expand Down

0 comments on commit ccdfe27

Please sign in to comment.