Skip to main content

aster_forge_api/
error.rs

1//! Framework-neutral API helper errors.
2/// Result type returned by API helper functions.
3pub type Result<T> = std::result::Result<T, ApiError>;
4
5/// Error type for generic API helper failures.
6#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
7#[error("{message}")]
8pub struct ApiError {
9    message: String,
10}
11
12impl ApiError {
13    /// Creates an API helper error with a message.
14    pub fn new(message: impl Into<String>) -> Self {
15        Self {
16            message: message.into(),
17        }
18    }
19
20    /// Returns the stored error message.
21    #[must_use]
22    pub fn message(&self) -> &str {
23        &self.message
24    }
25}