Give more context to errors in improv packet handling

This commit is contained in:
clerie 2024-12-23 17:35:43 +01:00
parent 62c4e16445
commit 6fd28effe5

View File

@ -371,7 +371,7 @@ impl ImprovDataFromPacket for RPCResultPacket {
// load string and append to results
let string_bytes = &raw_packet.data[current_string_begin..current_string_end+1];
let string = std::str::from_utf8(string_bytes).unwrap().to_string();
let string = std::str::from_utf8(string_bytes).context("Failed to convert response to UTF-8 string")?.to_string();
results.push(string);
// next data position
@ -379,7 +379,7 @@ impl ImprovDataFromPacket for RPCResultPacket {
}
return Ok(Self {
command_responded_to: RPCCommand::try_from(&raw_packet.data[0]).unwrap(),
command_responded_to: RPCCommand::try_from(&raw_packet.data[0]).context("Failed to determine RPC command this packet responds to")?,
results: results,
})
}