common: Add a error variant for unexpected header values

This commit is contained in:
Damir Jelić 2024-05-14 13:25:11 +02:00
parent b7b9816314
commit a12c38c532
2 changed files with 19 additions and 0 deletions

View File

@ -1,5 +1,10 @@
# [unreleased]
Improvements:
- Add the `InvalidHeaderValue` variant to the `DeserializationError` struct, for
cases where we receive a HTTP header with an unexpected value.
# 0.13.0
Bug fixes:

View File

@ -276,6 +276,20 @@ pub enum HeaderDeserializationError {
/// The given required header is missing.
#[error("missing header `{0}`")]
MissingHeader(String),
/// A header was received with a unexpected value.
#[error(
"The {header} header was received with an unexpected value, \
expected {expected}, received {unexpected}"
)]
InvalidHeaderValue {
/// The name of the header containing the invalid value.
header: String,
/// The value the header should have been set to.
expected: String,
/// The value we instead received and rejected.
unexpected: String,
},
}
/// An error that happens when Ruma cannot understand a Matrix version.