ENH: avoid to crash log when parsing sequence_id

Change-Id: I14ff7167cf4291a09d955d1ac295197470734546
This commit is contained in:
Stone Li 2023-03-30 15:08:50 +08:00 committed by Lane.Wei
parent 9606a04117
commit 82ee622ce3

View file

@ -2384,12 +2384,14 @@ int MachineObject::parse_json(std::string payload)
json jj = j["print"];
int sequence_id = 0;
if (jj.contains("sequence_id")) {
std::string str_seq = jj["sequence_id"].get<std::string>();
try {
sequence_id = stoi(str_seq);
}
catch(...) {
;
if (jj["sequence_id"].is_string()) {
std::string str_seq = jj["sequence_id"].get<std::string>();
try {
sequence_id = stoi(str_seq);
}
catch(...) {
;
}
}
}
if (jj.contains("command")) {