Skip to content

Commit a4b62ff

Browse files
committed
Update schemavalidator example to demonstrate GetError()
1 parent 384df14 commit a4b62ff

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

example/schemavalidator/schemavalidator.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "rapidjson/filereadstream.h"
77
#include "rapidjson/schema.h"
88
#include "rapidjson/stringbuffer.h"
9+
#include "rapidjson/prettywriter.h"
910

1011
using namespace rapidjson;
1112

@@ -67,6 +68,11 @@ int main(int argc, char *argv[]) {
6768
sb.Clear();
6869
validator.GetInvalidDocumentPointer().StringifyUriFragment(sb);
6970
fprintf(stderr, "Invalid document: %s\n", sb.GetString());
71+
// Detailed violation report is available as a JSON value
72+
sb.Clear();
73+
PrettyWriter<StringBuffer> w(sb);
74+
validator.GetError().Accept(w);
75+
fprintf(stderr, "Error report:\n%s\n", sb.GetString());
7076
return EXIT_FAILURE;
7177
}
7278
}

0 commit comments

Comments
 (0)