balanced / balanced-ruby

Balanced API library in ruby.
MIT License
111 stars 47 forks source link

"This should basically never happen" #204

Open JWesorick opened 9 years ago

JWesorick commented 9 years ago

So this exception wan't super helpful and also, despite what the exception says, it did happen. I was making a call to fetch a bank account:

Balanced::BankAccount.fetch("/bank_accounts/#{bank_account_id}")

where bank_account_id = nil. I understand the error is that the id is nil, but it seems like it should either be caught earlier or have a better exception message.

https://github.com/balanced/balanced-ruby/blob/master/lib/balanced/resources/resource.rb#L243

remear commented 9 years ago

@JWesorick I agree with making some changes here to better catch this error.

With that being said, this is also the result of manually building hrefs, which we ask API consumers not to do. You should store and use the href attribute supplied in API responses and not manually build them with stored IDs.

Irio commented 9 years ago

Did happen for me. :smile: