-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Map missing arrays from nil to [] ? #36
Comments
That is how the original version of this Gem worked. There are lots of undocumented fields, though. We could probably come up with something that builds a hashie object and then mixes in defaults depending on the type of Discogs resource we are building. data = get_release |
Hi Andrew, I’ve seen the old version, I’m heading for making it fool proof and fully reliable. I saw this: But this does not yet catch all possible failures We should come up with a definition, Actually throwing exceptions is a good thing if something really goes wrong, I actually believe, it should be an optinon when creating the stub object. While otherwise the stub should not throw exceptions at all, But then there should be some error object, saved in the stub object, These are obviously two very different ways of handling errors. I have to get my ass up, to push. ~eike Am 20.06.2014 um 01:12 schrieb Andrew Buntine notifications@github.com:
|
Hi Andrew, I forked on I’ll first try to fix my reported bugs as unintrusive as can be. I imagine to take a second step then, splitting out Discogs::Connection, Discogs::Request and Discogs::Response from the Discogs::Wrapper, but leaving the Wrapper api intact. Actually the discogs way of handling errors is less than robust today ... I could imagine to improve on that on the client side by prechecking the request data with something like json-schema… I write on the discogs api forum (as rockers) Am 20.06.2014 um 01:12 schrieb Andrew Buntine notifications@github.com:
|
release = discogs.get_release(...)
sometimes includes release.identifiers but sometimes does not.
(aka release.identifiers == nil)
I'd like to suggest to add some postprocessing to the Discogs::Wrapper
aka: release.identifiers=nil should automagically be mapped to release.identifiers={}
And let's look up all other pieces of the responses where such things might happen.
One might argue, that nil is the proper value here and we should not mess with this.
But on the other hand, the wrapper is ment to make life easy,
and it would be much more convenient, DRY and fool proof.
So actually the contract for release.identifiers would change from:
"might also return nil" to "always returns a hash"
which lessens the clients of the api to check for nil.
The text was updated successfully, but these errors were encountered: