Skip to main content

synapse_application/
error.rs

1use soma_ops::{DiagnosticCode, OperationName};
2
3/// Failure while loading or applying Synapse compatibility contracts.
4#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
5#[non_exhaustive]
6pub enum CompatibilityError {
7    /// A checked-in embedded contract could not be parsed or compiled.
8    #[error("embedded contract {artifact} is invalid: {message}")]
9    EmbeddedContract {
10        /// Artifact name.
11        artifact: &'static str,
12        /// Parse, compile, or cross-reference failure.
13        message: String,
14    },
15    /// A canonical operation was absent from the embedded registry.
16    #[error("unknown canonical operation: {0}")]
17    UnknownOperation(OperationName),
18    /// No legacy routing key maps to a canonical operation.
19    #[error("unknown legacy operation: tool={tool}, action={action}, subaction={subaction:?}")]
20    UnknownLegacyOperation {
21        /// Flux or Scout tool name.
22        tool: &'static str,
23        /// Legacy action.
24        action: String,
25        /// Optional legacy subaction.
26        subaction: Option<String>,
27    },
28    /// The legacy request was not an object or had a field with the wrong type.
29    #[error("invalid legacy request field {field}: {message}")]
30    InvalidLegacyRequest {
31        /// Invalid field.
32        field: String,
33        /// Corrective detail.
34        message: String,
35    },
36    /// A legacy request carried a field outside the resolved operation schema.
37    #[error("unknown field {field} for operation {operation}")]
38    UnknownField {
39        /// Canonical operation.
40        operation: OperationName,
41        /// Unknown field.
42        field: String,
43    },
44    /// JSON Schema validation rejected canonical parameters or output.
45    #[error("{kind} schema validation failed for {operation}: {details}")]
46    SchemaValidation {
47        /// Canonical operation.
48        operation: OperationName,
49        /// Parameters or result.
50        kind: &'static str,
51        /// Stable, joined validator messages.
52        details: String,
53    },
54    /// Legacy presentation fields requested conflicting formats.
55    #[error("legacy request has conflicting format and response_format values")]
56    ConflictingPresentation,
57    /// A legacy presentation format was unsupported.
58    #[error("unsupported legacy presentation format: {0}")]
59    InvalidPresentation(String),
60    /// A diagnostic code has no global surface projection.
61    #[error("unknown diagnostic projection: {0}")]
62    UnknownDiagnostic(DiagnosticCode),
63    /// A diagnostic is globally known but not declared by the operation.
64    #[error("diagnostic {code} is not declared by operation {operation}")]
65    DiagnosticNotDeclared {
66        /// Canonical operation.
67        operation: OperationName,
68        /// Undeclared diagnostic.
69        code: DiagnosticCode,
70    },
71}
72
73#[cfg(test)]
74#[path = "error_tests.rs"]
75mod tests;