1use std::sync::Arc;
20
21use crate::operations::ServingError;
25use crate::plugin::Plugin;
26
27#[derive(thiserror::Error)]
38pub enum Error<P: Plugin> {
39 #[error("invalid plugin configuration: {0}")]
40 Configuration(#[source] Arc<crate::ConfigError>),
41
42 #[error("plugin lifecycle machinery failed: {0}")]
43 Plugin(#[source] Arc<P::Error>),
44
45 #[error("plugin operation inventory failed: {0}")]
46 Inventory(#[source] Arc<crate::inventory::operations::Error>),
47
48 #[error("plugin operation table failed: {0}")]
49 Serving(#[source] Arc<ServingError>),
50
51 #[error("SDK generation context must be empty or exactly 32 nonzero bytes")]
52 GenerationContext,
53
54 #[error("plugin lifecycle state is unavailable for this phase")]
55 Phase,
56
57 #[error("plugin lifecycle machinery panicked")]
58 Panicked,
59
60 #[error("plugin lifecycle state lock is poisoned")]
61 Poisoned,
62}
63
64impl<P: Plugin> std::fmt::Debug for Error<P> {
69 fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
70 match self {
71 Self::Configuration(error) => formatter.debug_tuple("Configuration").field(error).finish(),
72 Self::Plugin(error) => formatter.debug_tuple("Plugin").field(error).finish(),
73 Self::Inventory(error) => formatter.debug_tuple("Inventory").field(error).finish(),
74 Self::Serving(error) => formatter.debug_tuple("Serving").field(error).finish(),
75 Self::GenerationContext => formatter.write_str("GenerationContext"),
76 Self::Phase => formatter.write_str("Phase"),
77 Self::Panicked => formatter.write_str("Panicked"),
78 Self::Poisoned => formatter.write_str("Poisoned"),
79 }
80 }
81}
82
83impl<P: Plugin> Clone for Error<P> {
84 fn clone(&self) -> Self {
85 match self {
86 Self::Configuration(error) => Self::Configuration(Arc::clone(error)),
87 Self::Plugin(error) => Self::Plugin(Arc::clone(error)),
88 Self::Inventory(error) => Self::Inventory(Arc::clone(error)),
89 Self::Serving(error) => Self::Serving(Arc::clone(error)),
90 Self::GenerationContext => Self::GenerationContext,
91 Self::Phase => Self::Phase,
92 Self::Panicked => Self::Panicked,
93 Self::Poisoned => Self::Poisoned,
94 }
95 }
96}
97
98