eggress_pproxy_compat/
error.rs1use crate::diagnostics::DiagnosticCode;
2
3#[derive(Debug, thiserror::Error)]
7pub enum CompatError {
8 #[error("unsupported protocol: {0}")]
10 UnsupportedProtocol(String),
11
12 #[error("unsupported feature: {feature}")]
14 UnsupportedFeature {
15 feature: &'static str,
16 detail: String,
17 },
18
19 #[error("invalid URI: {message}")]
21 InvalidUri { message: String },
22
23 #[error("invalid pproxy arguments: {message}")]
25 InvalidArgs { message: String },
26
27 #[error("config validation failed: {message}")]
29 ConfigValidation { message: String },
30
31 #[error("missing required argument: {0}")]
33 MissingArgument(String),
34}
35
36impl CompatError {
37 pub fn unsupported(feature: &'static str, detail: impl Into<String>) -> Self {
38 Self::UnsupportedFeature {
39 feature,
40 detail: detail.into(),
41 }
42 }
43
44 pub fn code(&self) -> DiagnosticCode {
46 match self {
47 Self::UnsupportedProtocol(_) => DiagnosticCode::UnsupportedProtocol,
48 Self::UnsupportedFeature { feature, .. } => {
49 crate::diagnostics::classify_unsupported_feature_code(feature)
50 }
51 Self::InvalidUri { .. } => DiagnosticCode::InvalidUriSyntax,
52 Self::InvalidArgs { .. } => DiagnosticCode::InvalidUriSyntax,
53 Self::ConfigValidation { .. } => DiagnosticCode::InvalidChainComposition,
54 Self::MissingArgument(_) => DiagnosticCode::MissingTarget,
55 }
56 }
57}