don't expect/panic crash whole bot on malformed json

This commit is contained in:
Dan Ballard 2022-04-27 13:28:13 -07:00
parent 22cdf9ae20
commit 32931f54d6
1 changed files with 4 additions and 3 deletions

View File

@ -117,9 +117,10 @@ impl UpdateBot {
o: 1,
d: resp_message,
};
let response_json =
serde_json::to_string(&response).expect("Error parsing json response");
cwtch.send_message(&profile.handle, convo_id, &response_json);
match serde_json::to_string(&response) {
OK(response_json) => cwtch.send_message(&profile.handle, convo_id, &response_json),
Err(e) => println!("Error parsing json response: {}", e.to_string()),
}
}
}
}