From 22559a8397793cdd71a34b937c276ed87b7b6216 Mon Sep 17 00:00:00 2001 From: Ethan Date: Thu, 19 Dec 2024 12:19:12 -0500 Subject: [PATCH] remove unwraps of HeaderName and HeaderValue (#137) --- src/rpc/webrtc.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/rpc/webrtc.rs b/src/rpc/webrtc.rs index 5811500..c263569 100644 --- a/src/rpc/webrtc.rs +++ b/src/rpc/webrtc.rs @@ -318,13 +318,16 @@ pub(crate) fn trailers_from_proto(proto: ResponseTrailers) -> HeaderMap { None => "0".to_string(), }; - match proto.status { - Some(ref status) => { - let key = HeaderName::from_str("Grpc-Message").unwrap(); - let val = HeaderValue::from_str(&status.message).unwrap(); - trailers.insert(key, val); + if let Some(ref status) = proto.status { + let key = HeaderName::from_str("Grpc-Message"); + let val = HeaderValue::from_str(status.message.trim()); + match (key, val) { + (Ok(k), Ok(v)) => { + trailers.insert(k, v); + } + (Err(e), _) => log::error!("Error parsing HeaderName: {e}"), + (_, Err(e)) => log::error!("Error parsing HeaderValue: {e}"), } - None => (), } let k = match HeaderName::from_str(status_name) {