aboutsummaryrefslogtreecommitdiff
path: root/src/message/handshake/clientinitreject.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/message/handshake/clientinitreject.rs')
-rw-r--r--src/message/handshake/clientinitreject.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/message/handshake/clientinitreject.rs b/src/message/handshake/clientinitreject.rs
index fca5388..6e4622b 100644
--- a/src/message/handshake/clientinitreject.rs
+++ b/src/message/handshake/clientinitreject.rs
@@ -21,10 +21,15 @@ impl HandshakeSerialize for ClientInitReject {
}
}
-impl From<VariantMap> for ClientInitReject {
- fn from(mut input: VariantMap) -> Self {
- ClientInitReject {
- error: input.remove("ErrorString").unwrap().try_into().unwrap(),
- }
+impl TryFrom<VariantMap> for ClientInitReject {
+ type Error = ProtocolError;
+
+ fn try_from(mut input: VariantMap) -> Result<Self, Self::Error> {
+ Ok(ClientInitReject {
+ error: input
+ .remove("ErrorString")
+ .ok_or_else(|| ProtocolError::MissingField("ErrorString".to_string()))?
+ .try_into()?,
+ })
}
}