{"action":"opened","issue":{"url":"https://api.github.com/repos/recurly/recurly-client-ruby/issues/270","repository_url":"https://api.github.com/repos/recurly/recurly-client-ruby","labels_url":"https://api.github.com/repos/recurly/recurly-client-ruby/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/recurly/recurly-client-ruby/issues/270/comments","events_url":"https://api.github.com/repos/recurly/recurly-client-ruby/issues/270/events","html_url":"https://github.com/recurly/recurly-client-ruby/issues/270","id":183889352,"number":270,"title":"Coupon redemptions produce unusable errors","user":{"login":"sdhull","id":50039,"avatar_url":"https://avatars.githubusercontent.com/u/50039?v=3","gravatar_id":"","url":"https://api.github.com/users/sdhull","html_url":"https://github.com/sdhull","followers_url":"https://api.github.com/users/sdhull/followers","following_url":"https://api.github.com/users/sdhull/following{/other_user}","gists_url":"https://api.github.com/users/sdhull/gists{/gist_id}","starred_url":"https://api.github.com/users/sdhull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdhull/subscriptions","organizations_url":"https://api.github.com/users/sdhull/orgs","repos_url":"https://api.github.com/users/sdhull/repos","events_url":"https://api.github.com/users/sdhull/events{/privacy}","received_events_url":"https://api.github.com/users/sdhull/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-10-19T07:47:10Z","updated_at":"2016-10-19T07:47:10Z","closed_at":null,"body":"My expectation is that I should be able to `rescue Recurly::Error => e` and then do `e.to_s` to get a customer-facing error message. Is this correct or no?\r\n\r\n```ruby\r\n[7] pry(main)> begin\r\n[7] pry(main)*   redemption = coupon.redeem! org.recurly_id\r\n[7] pry(main)* rescue => e\r\n[7] pry(main)*   err = e\r\n[7] pry(main)* end\r\n=> Recurly::Resource::Invalid\r\n[8] pry(main)> err.to_s\r\n=> \"\"\r\n[9] pry(main)> err.record\r\n=> #<Recurly::Coupon applies_for_months: nil, applies_to_all_plans: true, applies_to_non_plan_charges: false, coupon_code: \"free-99\", coupon_type: \"single_code\", created_at: Fri, 14 Oct 2016 00:50:13 +0000, description: \"Free ninety-nine!!!!! $99 credit\", discount_in_cents: #<Recurly::Money USD: 99_00>, discount_percent: nil, discount_type: \"dollars\", duration: \"forever\", free_trial_amount: nil, free_trial_unit: nil, invoice_description: \"Free ninety-nine!!!!! $99 credit\", max_redemptions: nil, max_redemptions_per_account: 1, name: \"Account Coupon Test\", plan_codes: [], redeem_by_date: nil, redemption_resource: \"account\", single_use: false, state: \"redeemable\", temporal_amount: nil, temporal_unit: nil, unique_template_code: nil>\r\n[10] pry(main)> err.record.errors\r\n=> {}\r\n```\r\n\r\nMeanwhile, if I build the Redemption manually as it's done in the `#redeem!` method,\r\n```ruby\r\n[23] pry(#<Recurly::Coupon>):1> begin\r\n[23] pry(#<Recurly::Coupon>):1*   Recurly::Redemption.from_response follow_link(:redeem,\r\n[23] pry(#<Recurly::Coupon>):1*     :body => redemption.to_xml\r\n[23] pry(#<Recurly::Coupon>):1*   )\r\n[23] pry(#<Recurly::Coupon>):1* rescue => e\r\n[23] pry(#<Recurly::Coupon>):1*   err = e\r\n[23] pry(#<Recurly::Coupon>):1* end\r\n...\r\n[26] pry(#<Recurly::Coupon>):1> puts e.response.body\r\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n<errors>\r\n  <error field=\"coupon.base\" symbol=\"maxed_out_for_account\">Coupon has reached max redemptions for this account</error>\r\n</errors>\r\n```\r\n\r\nSo a useful error _is_ returned by the API, it's simply inaccessible if you use the `#redeem!` method."}}
{"actor":{"display_login":"sdhull"}}