Commit c5eed0ac authored by legoc's avatar legoc
Browse files

(split) Better exit with exception when an unmanaged C++ application is called...

(split) Better exit with exception when an unmanaged C++ application is called with a bad info argument
parent 9ef053dd
......@@ -59,8 +59,8 @@ private:
typedef rapidjson::Document Object;
typedef rapidjson::Value Value;
void parse(Object & object, zmq::message_t * message);
void parse(Object & object, const std::string& string);
bool parse(Object & object, zmq::message_t * message);
bool parse(Object & object, const std::string& string);
}
}
......
......@@ -160,7 +160,9 @@ void This::initApplication(int argc, char *argv[]) {
// Get the info object.
json::Object infoObject;
json::parse(infoObject, info);
if (!json::parse(infoObject, info)) {
throw InvalidArgumentException("Bad format for info argument");
}
m_serverEndpoint = Endpoint::parse(infoObject[message::ApplicationIdentity::SERVER].GetString());
......
......@@ -73,20 +73,22 @@ std::string StringObject::toString() {
return m_buffer.GetString();
}
void parse(Object & object, zmq::message_t * message) {
bool parse(Object & object, zmq::message_t * message) {
rapidjson::ParseResult ok = object.Parse(static_cast<char *>(message->data()), message->size());
if (!ok) {
cerr << "Cannot parse message" << endl;
return false;
}
return true;
}
void parse(Object & object, const std::string& string) {
bool parse(Object & object, const std::string& string) {
rapidjson::ParseResult ok = object.Parse(static_cast<const char *>(string.c_str()), string.size());
if (!ok) {
cerr << "Cannot parse message" << endl;
return false;
}
return true;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment