File corruption in de-serialization, how to prevent a crash?

I use the boost graph library to work with graphs. I use boost :: serialization to write my graph to a file.

For testing purposes, I changed the integrity of the file. Now my program just crashed all the time. I was wondering if there is a way to prevent the crash (boost :: serialization does not throw exceptions).

And in the general case, for any type of file, without exception, created during parsing, where everything should be correct, is there a way?

Maybe the only solution is to write special serialization / de-serialization functions with exception handling?

Thanks!

Edit: there is a boost :: archive :: archive_exception file when all data is damaged or the file is missing. But if only a certain part of the file changes, it will fail ...

Edit2: I have to catch the input_stream_error exception, but I do not.

+4
source share
1 answer

A boost::archive_exception also raised in situations other than corruption of all data or a missing file. See Archive Exclusions for more details.

+1
source

All Articles