1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum OgmiosError {
8 #[error("WebSocket error: {0}")]
10 WebSocket(String),
11
12 #[error("HTTP handshake error: {0}")]
14 HttpHandshake(String),
15
16 #[error("HTTP error: {0}")]
18 Http(#[from] reqwest::Error),
19
20 #[error("JSON error: {0}")]
22 Json(#[from] serde_json::Error),
23
24 #[error("Server not ready: network synchronization is {synchronization:.2}%, minimum required is {minimum:.2}%")]
26 ServerNotReady {
27 synchronization: f64,
29 minimum: f64,
31 },
32
33 #[error("Connection closed unexpectedly")]
35 ConnectionClosed,
36
37 #[error("Socket is not open (state: {state})")]
39 SocketNotOpen {
40 state: String,
42 },
43
44 #[error("Invalid response from server: {message}")]
46 InvalidResponse {
47 message: String,
49 },
50
51 #[error("Request timed out after {timeout_ms}ms")]
53 Timeout {
54 timeout_ms: u64,
56 },
57
58 #[error("Intersection not found: {tip:?}")]
60 IntersectionNotFound {
61 tip: Option<String>,
63 },
64
65 #[error("Transaction submission failed: {0}")]
67 SubmissionError(String),
68
69 #[error("Transaction evaluation failed: {0}")]
71 EvaluationError(String),
72
73 #[error("Failed to acquire ledger state: {0}")]
75 AcquisitionError(String),
76
77 #[error("Query failed: {0}")]
79 QueryError(String),
80
81 #[error("URL parsing error: {0}")]
83 UrlParse(#[from] url::ParseError),
84
85 #[error("I/O error: {0}")]
87 Io(#[from] std::io::Error),
88
89 #[error("Channel send error: {0}")]
91 ChannelSend(String),
92
93 #[error("Channel receive error: receiver dropped")]
95 ChannelRecv,
96}
97
98pub type Result<T> = std::result::Result<T, OgmiosError>;