Add a diagnostic hint to input stream error#318
Conversation
|
Thanks for this, and welcome. Adding the stream offset to
Putting those together, the body could be something like: template<class T>
void load(T & t)
{
const std::streampos pos = is.tellg();
if(is >> t)
return;
std::string msg("at offset ");
msg += (std::streampos(-1) == pos)
? "<unknown>"
: std::to_string(static_cast<std::streamoff>(pos));
boost::serialization::throw_exception(
archive_exception(
archive_exception::input_stream_error,
msg.c_str()
)
);
}( Two more things to consider. First, Thanks again for taking a look at this area. |
This PR aims to save users some time when diagnosing an input_stream_error.
For example, a NaN value serialized as
<PlanningCost>-nan(ind)</PlanningCost>results in an input_stream_error exception when the file is reloaded.