tinygltf icon indicating copy to clipboard operation
tinygltf copied to clipboard

WriteGltfSceneToStream error reporting

Open malytomas opened this issue 3 years ago • 1 comments

Describe the issue

The function WriteGltfSceneToStream returns true unconditionally. I believe it is intended to return false when writing the file fails.

To Reproduce

  • OS: windows 10
  • Compiler, compiler version, compile options: msvc 2019

Expected behaviour

WriteGltfSceneToStream returns false on error.

malytomas avatar Aug 01 '22 15:08 malytomas

Both WriteGltfSceneToStream and WriteGltfSceneToFile returns true unconditionally.

I did some partial fix in this commit: https://github.com/syoyo/tinygltf/commit/81f7dbe53a112d05217a79bb1c986f9ada3b6631

WriteGltfSceneToFile would return false correctly when failed to write a file.

WriteGltfSceneToStream still returns true since there is no error check on stream write and also no error propagation mechanism when serializing JSON data to a string(related: https://github.com/syoyo/tinygltf/issues/332)

Your contribution of better error handling in Writer module is much appreciated!

syoyo avatar Aug 01 '22 16:08 syoyo

Closing via #408

syoyo avatar Mar 13 '23 16:03 syoyo