1use thiserror::Error;
4
5#[derive(Debug, Error, Clone, PartialEq, Eq)]
11pub enum ReflectError {
12 #[error("reflection JSON parse failed: {message}")]
14 InvalidJson {
15 raw: String,
17 message: String,
19 },
20
21 #[error("reflection schema validation failed: {message}")]
23 InvalidSchema {
24 raw: String,
26 message: String,
28 },
29
30 #[error("reflection admission failed: {message}")]
32 AdmissionRejected {
33 raw: String,
35 message: String,
37 },
38
39 #[error("reflection authority failed: {message}")]
41 AuthorityRejected {
42 raw: String,
44 message: String,
46 },
47}
48
49impl ReflectError {
50 #[must_use]
52 pub fn quarantine_payload(&self) -> &str {
53 match self {
54 Self::InvalidJson { raw, .. }
55 | Self::InvalidSchema { raw, .. }
56 | Self::AdmissionRejected { raw, .. }
57 | Self::AuthorityRejected { raw, .. } => raw,
58 }
59 }
60
61 #[must_use]
63 pub const fn quarantine_reason(&self) -> &'static str {
64 match self {
65 Self::InvalidJson { .. } => "invalid_json",
66 Self::InvalidSchema { .. } => "invalid_schema",
67 Self::AdmissionRejected { .. } => "admission_rejected",
68 Self::AuthorityRejected { .. } => "authority_rejected",
69 }
70 }
71
72 #[must_use]
74 pub fn detail(&self) -> &str {
75 match self {
76 Self::InvalidJson { message, .. }
77 | Self::InvalidSchema { message, .. }
78 | Self::AdmissionRejected { message, .. }
79 | Self::AuthorityRejected { message, .. } => message,
80 }
81 }
82}