Skip to content

Commit 2c1c79b

Browse files
committed
Implement Error for error_boundary::InvalidObject
Signed-off-by: Natalie Klestrup Röijezon <nat@nullable.se>
1 parent f0f47af commit 2c1c79b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

kube-core/src/error_boundary.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
//! Types for isolating deserialization failures. See [`DeserializeGuard`].
22
3-
use std::{borrow::Cow, fmt::Display};
3+
use std::borrow::Cow;
44

55
use k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta;
66
use serde::Deserialize;
77
use serde_value::DeserializerError;
8+
use thiserror::Error;
89

910
use crate::{PartialObjectMeta, Resource};
1011

@@ -17,7 +18,8 @@ use crate::{PartialObjectMeta, Resource};
1718
pub struct DeserializeGuard<K>(pub Result<K, InvalidObject>);
1819

1920
/// An object that failed to be deserialized by the [`DeserializeGuard`].
20-
#[derive(Debug, Clone)]
21+
#[derive(Debug, Clone, Error)]
22+
#[error("{error}")]
2123
pub struct InvalidObject {
2224
// Should ideally be D::Error, but we don't know what type it has outside of Deserialize::deserialize()
2325
// It *could* be Box<std::error::Error>, but we don't know that it is Send+Sync
@@ -27,12 +29,6 @@ pub struct InvalidObject {
2729
pub metadata: ObjectMeta,
2830
}
2931

30-
impl Display for InvalidObject {
31-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
32-
self.error.fmt(f)
33-
}
34-
}
35-
3632
impl<'de, K> Deserialize<'de> for DeserializeGuard<K>
3733
where
3834
K: Deserialize<'de>,

0 commit comments

Comments
 (0)