{"action":"closed","issue":{"url":"https://api.github.com/repos/miloyip/rapidjson/issues/385","labels_url":"https://api.github.com/repos/miloyip/rapidjson/issues/385/labels{/name}","comments_url":"https://api.github.com/repos/miloyip/rapidjson/issues/385/comments","events_url":"https://api.github.com/repos/miloyip/rapidjson/issues/385/events","html_url":"https://github.com/miloyip/rapidjson/issues/385","id":95309040,"number":385,"title":"How to handle Parse Errors in Document?","user":{"login":"cgmb","id":4886803,"avatar_url":"https://avatars.githubusercontent.com/u/4886803?v=3","gravatar_id":"","url":"https://api.github.com/users/cgmb","html_url":"https://github.com/cgmb","followers_url":"https://api.github.com/users/cgmb/followers","following_url":"https://api.github.com/users/cgmb/following{/other_user}","gists_url":"https://api.github.com/users/cgmb/gists{/gist_id}","starred_url":"https://api.github.com/users/cgmb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cgmb/subscriptions","organizations_url":"https://api.github.com/users/cgmb/orgs","repos_url":"https://api.github.com/users/cgmb/repos","events_url":"https://api.github.com/users/cgmb/events{/privacy}","received_events_url":"https://api.github.com/users/cgmb/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-15T23:06:25Z","updated_at":"2015-07-20T01:30:21Z","closed_at":"2015-07-20T01:30:21Z","body":"There seem to be some issues in the documentation for handling [parse errors](https://github.com/miloyip/rapidjson/blob/823b73189601a234dfa75f387130433fe7bedd38/doc/dom.md#parse-error-parseerror). Specifically, the example code uses a `reader` variable that is not declared. Is that supposed to be the document object?\r\n\r\n```c++\r\n#include \"rapidjson/document.h\"\r\n#include \"rapidjson/error/en.h\"\r\n\r\n// ...\r\nDocument d;\r\nif (d.Parse(json).HasParseError()) {\r\n    fprintf(stderr, \"\\nError(offset %u): %s\\n\", \r\n        (unsigned)reader.GetErrorOffset(),\r\n        GetParseError_En(reader.GetParseErrorCode()));\r\n    // ...\r\n}\r\n```\r\n\r\nI also notice that `ParseErrorCode GetParseError()` and `size_t GetParseOffet()` are listed as the functions used up near the top of that section. I didn't notice until just now, but there's a typo in `GetParseOffet`. That's not the whole story, though, because even with that corrected, they still don't match the names used in the example code. But even the example code doesn't seem to quite match the real names, either.\r\n\r\nMy working (?) code for this is:\r\n\r\n```c++\r\nDocument d;\r\nd.Parse(json);\r\nif (d.HasParseError()) {\r\n    fprintf(stderr, \"\\nError(offset %u): %s\\n\",\r\n        (unsigned)d.GetErrorOffset(),\r\n        GetParseError_En(d.GetParseError()));\r\n    // ...\r\n}\r\n```"}}