Skip to main content

rivet_adapter_lambda/
error.rs

1/// Error type for adapter configuration and runtime initialization.
2#[derive(Debug, thiserror::Error)]
3pub enum AdapterError {
4    #[error("lambda adapter is already configured")]
5    AlreadyConfigured,
6    #[error("lambda adapter is not configured; call configure() before handling requests")]
7    NotConfigured,
8    #[error("lambda adapter initialization failed: {0}")]
9    Initialization(String),
10}
11
12impl AdapterError {
13    /// Return an error indicating the adapter was configured more than once.
14    pub fn already_configured() -> Self {
15        Self::AlreadyConfigured
16    }
17
18    /// Return an error indicating the adapter was used before configuration.
19    pub fn not_configured() -> Self {
20        Self::NotConfigured
21    }
22
23    /// Return an initialization error with context from the failing step.
24    pub fn initialization(message: impl Into<String>) -> Self {
25        Self::Initialization(message.into())
26    }
27}