1use thiserror::Error;
2
3pub type ShellResult<T> = Result<T, ShellError>;
4
5#[derive(Debug, Error, Clone, PartialEq, Eq)]
6pub enum ShellError {
7 #[error("shell activator id must not be empty")]
8 EmptyActivatorId,
9 #[error("shell activator field '{field}' must not be empty")]
10 EmptyActivatorField { field: &'static str },
11 #[error("duplicate shell activator id '{id}'")]
12 DuplicateActivatorId { id: String },
13 #[error("shell activator '{id}' was not found")]
14 ActivatorNotFound { id: String },
15 #[error("shell activator update for '{id}' is empty")]
16 EmptyActivatorUpdate { id: String },
17 #[error("shell runtime is not initialized")]
18 NotInitialized,
19 #[error("shell host operation failed: {0}")]
20 Host(String),
21 #[error("shell activation '{id}' is disabled")]
22 ActivatorDisabled { id: String },
23 #[error("shell state changed concurrently (expected generation {expected}, found {actual})")]
24 ConcurrentMutation { expected: u64, actual: u64 },
25 #[error("shell Pins changed concurrently")]
26 ConcurrentPinMutation,
27 #[error("shell Pin limit reached ({max})")]
28 LimitReached { max: usize },
29 #[error("unsupported shell state version {version}")]
30 UnsupportedVersion { version: u32 },
31 #[error("invalid shell state: {0}")]
32 InvalidState(String),
33 #[error("shell state I/O failed: {0}")]
34 Io(String),
35}
36
37impl From<std::io::Error> for ShellError {
38 fn from(value: std::io::Error) -> Self {
39 Self::Io(value.to_string())
40 }
41}
42
43impl From<serde_json::Error> for ShellError {
44 fn from(value: serde_json::Error) -> Self {
45 Self::InvalidState(value.to_string())
46 }
47}