Conversation
The destructors of the JSON and the XML archive may throw despite being declared `noexcept`. This is addressed following the pattern used e.g. in std::stream: add (potentilally throwing) `close()` method that allows clients to handle the potential exceptions. Make the destructor silently swallow any exception.
|
@AzothAmmo The only CI failure for this PR is due to the error: The |
|
|
||
| //! Destructor, flushes the JSON | ||
| ~JSONOutputArchive() CEREAL_NOEXCEPT | ||
| //! Explicitly finishes the JSON output and flushes to the stream |
There was a problem hiding this comment.
By allowing this to be called outside of the destructor it does open up a case where the user calls close() then attempts to use the archive again. Have you tested what happens when this occurs? At minimum the description should mention that the archive will enter into undefined territory after calling this and further using the archive. I don't really want to put an overhead of checking against itsClosed to save the user in this case, as this is probably an off-nominal use case.
The destructors of the JSON and the XML archive may throw despite being declared
noexcept. This may lead to potential issues includingstd::terminate()being called if an exception is thrown during unwinding see the Core Guidelines: C.36: A destructor must not fail.This problem is addressed following the pattern analogous the one used used e.g. in
std::stream: add (potentially throwing)close()method that allows clients to handle the potential exceptions. Make the destructor silently swallow any exception.This addresses the issue #822.