lambda_simulator/
error.rs

1//! Error types for the Lambda runtime simulator.
2
3use thiserror::Error;
4
5/// Errors that can occur during simulation operations.
6#[derive(Error, Debug)]
7pub enum SimulatorError {
8    /// Error starting the HTTP server.
9    #[error("Failed to start server: {0}")]
10    ServerStart(String),
11
12    /// Error binding to the specified address.
13    #[error("Failed to bind to address: {0}")]
14    BindError(String),
15
16    /// Invalid configuration provided.
17    #[error("Invalid configuration: {0}")]
18    InvalidConfiguration(String),
19
20    /// Timeout occurred during operation.
21    #[error("Timeout occurred: {0}")]
22    Timeout(String),
23
24    /// Invocation not found.
25    #[error("Invocation not found: {0}")]
26    InvocationNotFound(String),
27}
28
29/// Errors that can occur during runtime operations.
30#[derive(Error, Debug)]
31pub enum RuntimeError {
32    /// Request ID not found.
33    #[error("Request ID not found: {0}")]
34    RequestIdNotFound(String),
35
36    /// Invalid request ID format.
37    #[error("Invalid request ID format: {0}")]
38    InvalidRequestId(String),
39
40    /// No invocation available.
41    #[error("No invocation available")]
42    NoInvocation,
43
44    /// Runtime not initialized.
45    #[error("Runtime not initialized")]
46    NotInitialized,
47
48    /// Runtime already initialized.
49    #[error("Runtime already initialized")]
50    AlreadyInitialized,
51
52    /// Invalid payload provided.
53    #[error("Invalid payload: {0}")]
54    InvalidPayload(String),
55}
56
57/// Errors that can occur when building invocations.
58#[derive(Error, Debug)]
59pub enum BuilderError {
60    /// Required field is missing.
61    #[error("Missing required field: {0}")]
62    MissingField(String),
63
64    /// Invalid freeze configuration.
65    #[error("Invalid freeze configuration: {0}")]
66    InvalidFreezeConfig(String),
67}
68
69/// Result type for simulator operations.
70pub type SimulatorResult<T> = Result<T, SimulatorError>;
71
72/// Result type for runtime operations.
73pub type RuntimeResult<T> = Result<T, RuntimeError>;