titanium_rs/
error.rs

1use thiserror::Error;
2
3/// Unified error type for the Titanium framework.
4#[derive(Debug, Error)]
5pub enum TitaniumError {
6    /// Errors from the Gateway (WebSocket, Sharding).
7    #[error("Gateway error: {0}")]
8    Gateway(#[from] titanium_gateway::error::GatewayError),
9
10    /// Errors from the HTTP client (REST API).
11    #[error("HTTP error: {0}")]
12    Http(#[from] titanium_http::error::HttpError),
13
14    /// Errors from the Framework (Command handling).
15    #[error("Framework error: {0}")]
16    Framework(String),
17
18    /// Errors from the Context (Interaction handling).
19    #[error("Context error: {0}")]
20    Context(#[from] ContextError),
21
22    /// Generic errors from user code or other sources.
23    #[error("Error: {0}")]
24    Other(#[from] Box<dyn std::error::Error + Send + Sync>),
25}
26
27/// Errors occurring within Context operations.
28#[derive(Debug, Error)]
29pub enum ContextError {
30    #[error("No interaction present in context")]
31    NoInteraction,
32    #[error("Already responded to interaction")]
33    AlreadyResponded,
34    #[error("HTTP error: {0}")]
35    Http(#[from] titanium_http::error::HttpError),
36}