Skip to content
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

:json_common adapter doesn't define it's own ParseError #164

Closed
iainbeeston opened this issue Apr 15, 2016 · 2 comments
Closed

:json_common adapter doesn't define it's own ParseError #164

iainbeeston opened this issue Apr 15, 2016 · 2 comments

Comments

@iainbeeston
Copy link

With most multi_json adapters, if I try to parse invalid JSON, a MultiJson::ParseError is raised. For example:

require 'multi_json'
MultiJson.use :json_gem
MultiJson.load("foo") # => raises MultiJson::ParseError: 795: unexpected token at 'foo'

However, the :json_common adapter raises a NameError:

require 'multi_json'
MultiJson.use :json_common
MultiJson.load("foo") # => raises NameError: uninitialized constant MultiJson::Adapters::JsonCommon::ParseError

This is because every adapter class defines a ParseError object (which MultiJson uses to catch parse errors - see here). However the :json_common adapter does not define it's own ParseError, leading to a NameError when MultiJson tries to access it.

It looks like defining a ParseError on the :json_common adapter would fix the issue (though what is the correct parse error class to catch?)

@rwz
Copy link
Member

rwz commented Apr 15, 2016

Actually, JsonCommon is not an adapter you should use. It's an abstract class and is there only so JsonGem and JsonPure can inherit from it.

We should probably communicate it somehow, I know it's confusing since it's sitting in the adapters folder with all other legit adapters.

@rwz rwz closed this as completed Apr 15, 2016
@iainbeeston
Copy link
Author

Ah I wondered as much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants