{"action":"created","issue":{"url":"https://api.github.com/repos/ohler55/oj/issues/291","repository_url":"https://api.github.com/repos/ohler55/oj","labels_url":"https://api.github.com/repos/ohler55/oj/issues/291/labels{/name}","comments_url":"https://api.github.com/repos/ohler55/oj/issues/291/comments","events_url":"https://api.github.com/repos/ohler55/oj/issues/291/events","html_url":"https://github.com/ohler55/oj/issues/291","id":135459250,"number":291,"title":"JSON::ParserError is not descendant of StandardError after calling mimic_JSON","user":{"login":"RST-J","id":4967885,"avatar_url":"https://avatars.githubusercontent.com/u/4967885?v=3","gravatar_id":"","url":"https://api.github.com/users/RST-J","html_url":"https://github.com/RST-J","followers_url":"https://api.github.com/users/RST-J/followers","following_url":"https://api.github.com/users/RST-J/following{/other_user}","gists_url":"https://api.github.com/users/RST-J/gists{/gist_id}","starred_url":"https://api.github.com/users/RST-J/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RST-J/subscriptions","organizations_url":"https://api.github.com/users/RST-J/orgs","repos_url":"https://api.github.com/users/RST-J/repos","events_url":"https://api.github.com/users/RST-J/events{/privacy}","received_events_url":"https://api.github.com/users/RST-J/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-02-22T15:55:42Z","updated_at":"2016-02-26T11:25:14Z","closed_at":null,"body":"It seems like my 'everything is fine' response to #290 was a bit too quick, because I only checked for the parse error to be `JSON::ParserError` rather than `Oj::ParseError`. For code explicitly handling `JSON::ParserError` it is actually fine, but for a generic rescue-Clause which handles `StandardError` and children, it is not. Here is a gist to illustrate my observations:\r\n```ruby\r\nrequire 'json'\r\nrequire 'oj'\r\n\r\ndata = '\"invalid\"'\r\n\r\nbegin\r\n  JSON.parse(data)\r\nrescue => e\r\n  puts 'Caught a StandardError'\r\n  puts e.class\r\nend\r\n\r\nOj.load(data)\r\nOj.mimic_JSON\r\nOj.load(data)\r\n\r\nbegin\r\n  JSON.parse(data)\r\nrescue => e\r\n  puts 'Caught a StandardError in non-quirks mode'\r\n  puts e.class\r\nrescue Exception => e\r\n  puts 'Caught an Exception in non-quirks mode'\r\n  puts e.class\r\nend\r\n\r\nbegin\r\n  JSON.parse(data, quirks_mode: true)\r\nrescue => e\r\n  puts 'Caught a StandardError in quirks mode'\r\n  puts e.class\r\nrescue Exception => e\r\n  puts 'Caught an Exception in quirks mode'\r\n  puts e.class\r\nend\r\n```\r\nThe output of this is:\r\n```\r\nCaught a StandardError\r\nJSON::ParserError\r\nCaught an Exception in non-quirks mode\r\nJSON::ParserError\r\n```\r\nFirst observation is that for oj's `load` method everything remains unchanged, but when using `mimic_JSON` there are two changes:\r\n* the default setting for `quirks_mode` is not applied any more (which was at least the case for 2.14.2, don't know whether this change was intentionally - by intuition I'd say it isn't)\r\n* The class hierarchy for `JSON::ParserError` changes, it is not a descendant of `StandardError` any more which makes it fall through all anonymous rescue-clauses"},"comment":{"url":"https://api.github.com/repos/ohler55/oj/issues/comments/189230866","html_url":"https://github.com/ohler55/oj/issues/291#issuecomment-189230866","issue_url":"https://api.github.com/repos/ohler55/oj/issues/291","id":189230866,"user":{"login":"RST-J","id":4967885,"avatar_url":"https://avatars.githubusercontent.com/u/4967885?v=3","gravatar_id":"","url":"https://api.github.com/users/RST-J","html_url":"https://github.com/RST-J","followers_url":"https://api.github.com/users/RST-J/followers","following_url":"https://api.github.com/users/RST-J/following{/other_user}","gists_url":"https://api.github.com/users/RST-J/gists{/gist_id}","starred_url":"https://api.github.com/users/RST-J/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RST-J/subscriptions","organizations_url":"https://api.github.com/users/RST-J/orgs","repos_url":"https://api.github.com/users/RST-J/repos","events_url":"https://api.github.com/users/RST-J/events{/privacy}","received_events_url":"https://api.github.com/users/RST-J/received_events","type":"User","site_admin":false},"created_at":"2016-02-26T11:25:14Z","updated_at":"2016-02-26T11:25:14Z","body":"Thanks again. I played around with it and think its both fine now, the error class hierarchy and using quirks mode by default. :+1: "}}