1
0
mirror of https://github.com/matrix-org/matrix-authentication-service.git synced 2025-08-07 17:03:01 +03:00

Make ClientErrorCode.error_description optional.

This commit is contained in:
Doug
2023-05-09 13:58:22 +01:00
committed by Quentin Gliech
parent fb06c69a8b
commit 7aae66e182

View File

@@ -30,7 +30,8 @@ pub struct ClientError {
pub error: ClientErrorCode, pub error: ClientErrorCode,
/// A human-readable description of the error. /// A human-readable description of the error.
pub error_description: Cow<'static, str>, #[serde(skip_serializing_if = "Option::is_none")]
pub error_description: Option<Cow<'static, str>>,
} }
impl ClientError { impl ClientError {
@@ -39,14 +40,14 @@ impl ClientError {
pub const fn new(error: ClientErrorCode, error_description: &'static str) -> Self { pub const fn new(error: ClientErrorCode, error_description: &'static str) -> Self {
Self { Self {
error, error,
error_description: Cow::Borrowed(error_description), error_description: Some(Cow::Borrowed(error_description)),
} }
} }
/// Changes the description of this `ClientError` with the given `String`. /// Changes the description of this `ClientError` with the given `String`.
#[must_use] #[must_use]
pub fn with_description(mut self, description: String) -> Self { pub fn with_description(mut self, description: String) -> Self {
self.error_description = Cow::Owned(description); self.error_description = Some(Cow::Owned(description));
self self
} }
} }