use thiserror::Error;
#[derive(Error, Debug)]
pub enum OgmiosError {
#[error("WebSocket error: {0}")]
WebSocket(String),
#[error("HTTP handshake error: {0}")]
HttpHandshake(String),
#[error("HTTP error: {0}")]
Http(#[from] reqwest::Error),
#[error("JSON error: {0}")]
Json(#[from] serde_json::Error),
#[error("Server not ready: network synchronization is {synchronization:.2}%, minimum required is {minimum:.2}%")]
ServerNotReady {
synchronization: f64,
minimum: f64,
},
#[error("Connection closed unexpectedly")]
ConnectionClosed,
#[error("Socket is not open (state: {state})")]
SocketNotOpen {
state: String,
},
#[error("Invalid response from server: {message}")]
InvalidResponse {
message: String,
},
#[error("Request timed out after {timeout_ms}ms")]
Timeout {
timeout_ms: u64,
},
#[error("Intersection not found: {tip:?}")]
IntersectionNotFound {
tip: Option<String>,
},
#[error("Transaction submission failed: {0}")]
SubmissionError(String),
#[error("Transaction evaluation failed: {0}")]
EvaluationError(String),
#[error("Failed to acquire ledger state: {0}")]
AcquisitionError(String),
#[error("Query failed: {0}")]
QueryError(String),
#[error("URL parsing error: {0}")]
UrlParse(#[from] url::ParseError),
#[error("I/O error: {0}")]
Io(#[from] std::io::Error),
#[error("Channel send error: {0}")]
ChannelSend(String),
#[error("Channel receive error: receiver dropped")]
ChannelRecv,
}
pub type Result<T> = std::result::Result<T, OgmiosError>;