Skip to main content

zlayer_init_actions/
error.rs

1//! Init action error types
2
3use std::time::Duration;
4use thiserror::Error;
5
6/// Init action errors
7#[derive(Debug, Error)]
8pub enum InitError {
9    /// TCP connection failed
10    #[error("TCP connection to {host}:{port} failed: {reason}")]
11    TcpFailed {
12        host: String,
13        port: u16,
14        reason: String,
15    },
16
17    /// HTTP request failed
18    #[error("HTTP request to {url} failed: {reason}")]
19    HttpFailed { url: String, reason: String },
20
21    /// Command execution failed
22    #[error("Command '{command}' failed with exit code {code}")]
23    CommandFailed {
24        command: String,
25        code: i32,
26        stdout: String,
27        stderr: String,
28    },
29
30    /// Timeout exceeded
31    #[error("Timeout exceeded: {timeout:?}")]
32    Timeout { timeout: Duration },
33
34    /// Action not found
35    #[error("Unknown init action: {0}")]
36    UnknownAction(String),
37
38    /// Invalid parameters
39    #[error("Invalid parameters for action '{action}': {reason}")]
40    InvalidParams { action: String, reason: String },
41
42    /// S3 operation failed
43    #[cfg(feature = "s3")]
44    #[error("S3 operation failed for {bucket}/{key}: {reason}")]
45    S3Failed {
46        bucket: String,
47        key: String,
48        reason: String,
49    },
50}
51
52pub type Result<T, E = InitError> = std::result::Result<T, E>;