Re: [Boost-users] boost::serialization throws random exceptions
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Adrian Grigore Sent: Saturday, February 03, 2007 9:11 AM To: boost-users@lists.boost.org Subject: Re: [Boost-users] boost::serialization throws random exceptions
Robert Ramey wrote the following on 2/3/2007 1:30 AM:
a) catch the archive exceptions and display an error message which describes what kind of exception has been thrown.
I did something similar, but it is still a poor workaround. I save data incrementally and rotate savefile names to make sure the player does not lose all data, but just the changes since the last increment. Still, losing all game progress since the last savefile increment is a major turnoff for most players.
[Nat] I think he was suggesting that you do that as a diagnostic measure to help discover and solve the problem you're encountering. I don't think he meant for you merely to put in the catch code and release the program.
c) Just a while guess - thrown from load binary might suggest either the file isn't being opened binary, or the size of data being read isn't the same as what's being saved.
I doubt that since there is only one save and one load routine in my application. If I opened the file as text when saving and as binary when loading this would always fail. But in my case everything is working fine most of the time.
[Nat] But you COULD be having troubles even if you open the file as text both for save and for load. In fact, the magic value 26 is a strong hint that this may be the trouble. A byte containing binary 26 may, in text mode, be interpreted as the character ctrl-Z -- which was the traditional MS-DOS EOF marker. Please try Robert's suggestion: ensure that you're opening the file using the binary flag both for saving and for loading the file.
Nate, Nat Goodspeed wrote the following on 2/3/2007 8:39 PM:
[Nat] But you COULD be having troubles even if you open the file as text both for save and for load. In fact, the magic value 26 is a strong hint that this may be the trouble. A byte containing binary 26 may, in text mode, be interpreted as the character ctrl-Z -- which was the traditional MS-DOS EOF marker.
Thanks very much for pointing this out again. I Misunderstood Robert's suggestion and just checked that I open the archives in binary mode, not the file itself. Once I fixed that everything was running smoothly. Robert, Nate: Thanks very much for your help! :-) Adrian
participants (2)
-
Adrian Grigore
-
Nat Goodspeed