Skip to main content

slop_ai/
error.rs

1//! Error types for the SLOP SDK.
2//!
3//! All fallible operations return [`Result<T>`], which is an alias for
4//! `std::result::Result<T, SlopError>`.
5
6use thiserror::Error;
7
8/// Errors produced by the SLOP SDK.
9#[derive(Error, Debug)]
10pub enum SlopError {
11    #[error("serialization error: {0}")]
12    Serialization(#[from] serde_json::Error),
13
14    #[error("no handler for action '{action}' at path '{path}'")]
15    HandlerNotFound { path: String, action: String },
16
17    #[error("action failed: {message}")]
18    ActionFailed { code: String, message: String },
19
20    #[error("transport error: {0}")]
21    Transport(String),
22
23    #[error("connection closed")]
24    ConnectionClosed,
25}
26
27pub type Result<T> = std::result::Result<T, SlopError>;