chore: cleanup errors

This commit is contained in:
Zomatree
2025-07-31 10:47:04 +01:00
parent d7cf809424
commit 789dedd9f1
3 changed files with 29 additions and 26 deletions

View File

@@ -38,16 +38,22 @@ impl ProtocolConfiguration {
match self.format {
ProtocolFormat::Json => {
if let Message::Text(text) = msg {
serde_json::from_str(text).to_internal_error()
// Log the error in-case we make a breaking change to the payload
serde_json::from_str(text)
.capture_error()
.map_err(|_| create_error!(UnprocessableEntity))
} else {
Err(create_error!(InternalError))
Err(create_error!(UnprocessableEntity))
}
}
ProtocolFormat::Msgpack => {
if let Message::Binary(buf) = msg {
rmp_serde::from_slice(buf).to_internal_error()
rmp_serde::from_slice(buf)
.capture_error()
.map_err(|_| create_error!(UnprocessableEntity))
} else {
Err(create_error!(InternalError))
Err(create_error!(UnprocessableEntity))
}
}
}