From ccdfe277e6f4da2298fd7f74aaf7d48202a98af9 Mon Sep 17 00:00:00 2001 From: Brandur Date: Mon, 29 Jul 2019 13:50:56 -0700 Subject: [PATCH] Make `CardError`'s `code` parameter named instead of positional 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. --- lib/stripe/errors.rb | 3 +-- lib/stripe/stripe_client.rb | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/stripe/errors.rb b/lib/stripe/errors.rb index 9eb4f6edf..24254e126 100644 --- a/lib/stripe/errors.rb +++ b/lib/stripe/errors.rb @@ -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, diff --git a/lib/stripe/stripe_client.rb b/lib/stripe/stripe_client.rb index 126c5d96e..e1dafddad 100644 --- a/lib/stripe/stripe_client.rb +++ b/lib/stripe/stripe_client.rb @@ -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