mirror of
https://git.mirrors.martin98.com/https://github.com/syoyo/tinygltf.git
synced 2025-08-14 05:45:57 +08:00
Check the failure of RapidJson Accept(). Fixes #332
TODO: Better error reporting when Accept() failed.
This commit is contained in:
parent
3d4150419e
commit
544969b732
10
tiny_gltf.h
10
tiny_gltf.h
@ -3092,11 +3092,17 @@ std::string JsonToString(const json &o, int spacing = -1) {
|
||||
StringBuffer buffer;
|
||||
if (spacing == -1) {
|
||||
Writer<StringBuffer> writer(buffer);
|
||||
o.Accept(writer);
|
||||
// TODO: Better error handling.
|
||||
// https://github.com/syoyo/tinygltf/issues/332
|
||||
if (!o.Accept(writer)) {
|
||||
return "tiny_gltf::JsonToString() failed rapidjson conversion";
|
||||
}
|
||||
} else {
|
||||
PrettyWriter<StringBuffer> writer(buffer);
|
||||
writer.SetIndent(' ', uint32_t(spacing));
|
||||
o.Accept(writer);
|
||||
if (!o.Accept(writer)) {
|
||||
return "tiny_gltf::JsonToString() failed rapidjson conversion";
|
||||
}
|
||||
}
|
||||
return buffer.GetString();
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user