Skip to main content

panproto_protocols/
error.rs

1//! Error types for protocol operations.
2
3/// Errors from protocol parsing or definition.
4#[derive(Debug, thiserror::Error)]
5#[non_exhaustive]
6pub enum ProtocolError {
7    /// A theory colimit failed during protocol construction.
8    #[error("theory colimit failed: {0}")]
9    ColimitFailed(#[from] panproto_gat::GatError),
10
11    /// A schema building step failed.
12    #[error("schema build failed: {0}")]
13    SchemaBuild(#[from] panproto_schema::SchemaError),
14
15    /// JSON parsing failed.
16    #[error("JSON error: {0}")]
17    Json(#[from] serde_json::Error),
18
19    /// The input format was invalid or unsupported.
20    #[error("parse error: {0}")]
21    Parse(String),
22
23    /// A required field is missing in the input.
24    #[error("missing field: {0}")]
25    MissingField(String),
26
27    /// The input references an unknown type or definition.
28    #[error("unknown reference: {0}")]
29    UnknownRef(String),
30
31    /// Emit/serialization failed.
32    #[error("emit error: {0}")]
33    Emit(String),
34
35    /// The schema does not match the expected protocol structure.
36    #[error("protocol mismatch: expected {expected}, got vertex kinds {actual}")]
37    ProtocolMismatch {
38        /// Expected protocol name.
39        expected: String,
40        /// Actual vertex kinds found.
41        actual: String,
42    },
43}