breese / trial.protocol

Network wire protocols
11 stars 4 forks source link

trial::protocol::json::iarchive(raw_result) >> trial::dynamic::variable{} fails on bad input #33

Closed vinipsmaker closed 5 years ago

vinipsmaker commented 5 years ago

The following will fail on bad input:

void f(boost::string_view raw_result)
{
    trial::dynamic::variable result;
    try {
        trial::protocol::json::iarchive archive(raw_result);
        archive >> result
    } catch (...) {
        // ...
    }
}

The serialization code doesn't handle the trial::protocol::json::token::symbol::error enumeration:

https://github.com/breese/trial.protocol/blob/e86adaf66b3847e12cee5affea4d643851e3f7b5/include/trial/protocol/json/serialization/dynamic/variable.hpp#L137

I have some hurry to solve this issue then I'll probably send a PR (after I solve the issue on my own tree). But which error handling do you think it fits into Trial.Protocol design? Is throwing an exception fine here?

breese commented 5 years ago

Yes, exceptions are fine from the serialization