Skip to main content

binary_options_tools_core_pre/
error.rs

1use std::time::Duration;
2
3#[derive(thiserror::Error, Debug)]
4pub enum CoreError {
5    #[error("WebSocket error: {0}")]
6    WebSocket(Box<tokio_tungstenite::tungstenite::Error>),
7    #[error("Channel receiver error: {0}")]
8    ChannelReceiver(#[from] kanal::ReceiveError),
9    #[error("Channel sender error: {0}")]
10    ChannelSender(#[from] kanal::SendError),
11    #[error("Connection error: {0}")]
12    Connection(#[from] super::connector::ConnectorError),
13    #[error("Failed to join task: {0}")]
14    JoinTask(#[from] tokio::task::JoinError),
15    /// Error for when a module is not found.
16    #[error("Module '{0}' not found.")]
17    ModuleNotFound(String),
18
19    #[error("Failed to parse ssid: {0}")]
20    SsidParsing(String),
21    #[error("HTTP request error: {0}")]
22    HttpRequest(String),
23
24    #[error("Lightweight [{0} Module] loop exited unexpectedly.")]
25    LightweightModuleLoop(String),
26
27    #[error("Api [{0} Module] loop exited unexpectedly.")]
28    ApiModuleLoop(String),
29
30    #[error("Other error: {0}")]
31    Other(String),
32
33    #[error("Poison error: {0}")]
34    Poison(String),
35
36    #[error("Serialization error: {0}")]
37    Serde(#[from] serde_json::Error),
38
39    #[error("IO error: {0}")]
40    Io(#[from] std::io::Error),
41
42    #[error("Tracing error: {0}")]
43    Tracing(String),
44
45    #[error("Failed to execute '{task}' task before the maximum allowed time of '{duration:?}'")]
46    TimeoutError { task: String, duration: Duration },
47}
48
49pub type CoreResult<T> = std::result::Result<T, CoreError>;