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
1 changed files with 8 additions and 6 deletions

View File

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