tor-cell: Return a useful error when restrist_msg rejects a command.

This commit is contained in:
Nick Mathewson 2023-02-08 09:11:03 -05:00
parent 48ab7b0463
commit 1c1dec0948
1 changed files with 3 additions and 2 deletions

View File

@ -156,9 +156,10 @@ macro_rules! restricted_msg {
$(
_ => Self::$unrecognized($unrec_type::decode_with_cmd(cmd, r)?),
)?
// TODO: This message is too terse! This message type should maybe take a Cow?
#[allow(unreachable_patterns)] // This is unreachable if we had an Unrecognized variant above.
_ => return Err($crate::restrict::tor_bytes::Error::InvalidMessage("Unexpected command".into())),
_ => return Err($crate::restrict::tor_bytes::Error::InvalidMessage(
format!("Unexpected command {} in {}", cmd, stringify!($name)).into()
)),
})
}
}