Update schemavalidator example to demonstrate GetError()
This commit is contained in:
parent
384df14e6d
commit
a4b62ff61b
@ -6,6 +6,7 @@
|
|||||||
#include "rapidjson/filereadstream.h"
|
#include "rapidjson/filereadstream.h"
|
||||||
#include "rapidjson/schema.h"
|
#include "rapidjson/schema.h"
|
||||||
#include "rapidjson/stringbuffer.h"
|
#include "rapidjson/stringbuffer.h"
|
||||||
|
#include "rapidjson/prettywriter.h"
|
||||||
|
|
||||||
using namespace rapidjson;
|
using namespace rapidjson;
|
||||||
|
|
||||||
@ -67,6 +68,11 @@ int main(int argc, char *argv[]) {
|
|||||||
sb.Clear();
|
sb.Clear();
|
||||||
validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);
|
validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);
|
||||||
fprintf(stderr, "Invalid document: %s\n", sb.GetString());
|
fprintf(stderr, "Invalid document: %s\n", sb.GetString());
|
||||||
|
// Detailed violation report is available as a JSON value
|
||||||
|
sb.Clear();
|
||||||
|
PrettyWriter<StringBuffer> w(sb);
|
||||||
|
validator.GetError().Accept(w);
|
||||||
|
fprintf(stderr, "Error report:\n%s\n", sb.GetString());
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user