Skip to main content

hooksmith_core/
error.rs

1use thiserror::Error;
2
3/// Transport-level errors shared across all hooksmith service crates.
4///
5/// Service-specific error types should wrap this via `#[from]` so that generic
6/// code can pattern-match on network or JSON failures without knowing which
7/// service produced them.
8///
9/// # Example
10///
11/// ```rust,ignore
12/// #[derive(Debug, thiserror::Error)]
13/// pub enum DiscordError {
14///     #[error(transparent)]
15///     Core(#[from] hooksmith_core::CoreError),
16///
17///     #[error("Discord API error {status}: {body}")]
18///     Api { status: u16, body: String },
19/// }
20/// ```
21#[non_exhaustive]
22#[derive(Debug, Error)]
23pub enum CoreError {
24    /// An HTTP or network-level failure from the underlying [`reqwest`] client.
25    #[error("network error: {0}")]
26    Network(#[from] reqwest::Error),
27
28    /// JSON serialization or deserialization failed.
29    #[error("JSON error: {0}")]
30    Json(#[from] serde_json::Error),
31}