diff --git a/src/hyperapp.rs b/src/hyperapp.rs index f0b8e88..2986029 100644 --- a/src/hyperapp.rs +++ b/src/hyperapp.rs @@ -267,9 +267,16 @@ where return Ok(r); } - let e = serde_json::from_slice::(&response_bytes) - .expect("Failed to deserialize response to send()"); - return Err(AppSendError::SendError(e)); + match serde_json::from_slice::(&response_bytes) { + Ok(e) => Err(AppSendError::SendError(e)), + Err(err) => { + error!( + "Failed to deserialize response in send(): {} (payload: {:?})", + err, response_bytes + ); + Err(AppSendError::BuildError(BuildError::NoBody)) + } + } } pub async fn send_rmp(request: Request) -> Result @@ -292,9 +299,16 @@ where return Ok(r); } - let e = rmp_serde::from_slice::(&response_bytes) - .expect("Failed to deserialize response to send()"); - return Err(AppSendError::SendError(e)); + match rmp_serde::from_slice::(&response_bytes) { + Ok(e) => Err(AppSendError::SendError(e)), + Err(err) => { + error!( + "Failed to deserialize response in send_rmp(): {} (payload: {:?})", + err, response_bytes + ); + Err(AppSendError::BuildError(BuildError::NoBody)) + } + } } // Enum defining the state persistance behaviour