Skip to main content

supercode_interchange/
error.rs

1//! Errors produced while loading, translating, and persisting sessions.
2
3use thiserror::Error;
4
5/// Result type for interchange operations.
6pub type Result<T> = std::result::Result<T, InterchangeError>;
7
8/// An error at a native session-format boundary.
9#[derive(Debug, Error)]
10#[non_exhaustive]
11pub enum InterchangeError {
12    /// A serialized value could not be decoded or encoded.
13    #[error("failed to process session JSON: {0}")]
14    Decode(#[from] serde_json::Error),
15
16    /// A persisted session artifact violated its framing or schema contract.
17    #[error("invalid session artifact: {0}")]
18    InvalidSession(String),
19
20    /// A filesystem operation failed.
21    #[error("io error: {0}")]
22    Io(#[from] std::io::Error),
23
24    /// A format-specific operation failed without a narrower stable category.
25    #[error("{0}")]
26    Other(String),
27}