1use schemars::JsonSchema;
2use serde::Serialize;
3use thiserror::Error;
4
5#[derive(Debug, Error, Clone, Serialize, JsonSchema)]
7pub enum IIIError {
8 #[error("iii is not connected")]
9 NotConnected,
10 #[error("invocation timed out")]
11 Timeout,
12 #[error("runtime error: {0}")]
13 Runtime(String),
14 #[error("remote error ({code}): {message}")]
15 Remote {
16 code: String,
17 message: String,
18 stacktrace: Option<String>,
19 },
20 #[error("handler error: {0}")]
21 Handler(String),
22 #[error("serialization error: {0}")]
23 Serde(String),
24 #[error("websocket error: {0}")]
25 WebSocket(String),
26}
27
28impl From<serde_json::Error> for IIIError {
29 fn from(err: serde_json::Error) -> Self {
30 IIIError::Serde(err.to_string())
31 }
32}
33
34impl From<tokio_tungstenite::tungstenite::Error> for IIIError {
35 fn from(err: tokio_tungstenite::tungstenite::Error) -> Self {
36 IIIError::WebSocket(err.to_string())
37 }
38}