mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-10-28 03:20:15 +01:00
Add parse error codes and API for converting error code to text.
Parse errors is represented as enum type `ParseErrorCode`. Error texts are optional for user. Added `GetParseError_En()` in `error/en.h`, user can localize this file into other files. User may dynamically change the locale in runtime.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "rapidjson/prettywriter.h"
|
||||
#include "rapidjson/filereadstream.h"
|
||||
#include "rapidjson/filewritestream.h"
|
||||
#include "rapidjson/error/en.h"
|
||||
|
||||
using namespace rapidjson;
|
||||
|
||||
@@ -21,7 +22,7 @@ int main(int, char*[]) {
|
||||
|
||||
// JSON reader parse from the input stream and let writer generate the output.
|
||||
if (!reader.Parse<kParseValidateEncodingFlag>(is, writer)) {
|
||||
fprintf(stderr, "\nError(%u): %s\n", (unsigned)reader.GetErrorOffset(), reader.GetParseError());
|
||||
fprintf(stderr, "\nError(%u): %s\n", (unsigned)reader.GetErrorOffset(), GetParseError_En(reader.GetParseErrorCode()));
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user