I'm trying to dump the protobuf message object using MessageToJsonString() 
function 
but encountering an exception. Sample code is as below followed by the 
output without try{}catch()


ResultRecord* GetSampleData()
{
    auto resultRecord = std::make_unique<ResultRecord>();
    ....
    //Filling resultRecord
    ....
    return resultRecord.release();
}
int main(int, char**) {

    //Getting RecordData through Protobuf
    auto data = GetSampleData();

    if(data){
        std::string str;
        google::protobuf::util::JsonOptions opts;
        opts.add_whitespace = true;
        try{
            google::protobuf::util::MessageToJsonString(*(data), &str, opts);
        }
        catch(std::exception e)
        {
            std::cout<< e.what()<<std::endl;
        }
        std::cout<<str<<std::endl;
    }
    return 0;
}

Output :

terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error -1

I'm not sure what to do to debug this. Can someone point me in right 
direction ?

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/protobuf/e4f70f39-40cb-4801-9c96-da46e3dd3830%40googlegroups.com.

Reply via email to