Skip to main content

rsenv/infrastructure/
error.rs

1//! Infrastructure-level errors (wraps application errors)
2
3use thiserror::Error;
4
5use crate::application::ApplicationError;
6
7/// Infrastructure errors wrap application errors and add I/O-level concerns.
8#[derive(Error, Debug)]
9pub enum InfraError {
10    #[error("{0}")]
11    Application(#[from] ApplicationError),
12
13    #[error("I/O error: {context}")]
14    Io {
15        context: String,
16        #[source]
17        source: std::io::Error,
18    },
19
20    #[error("sops command failed: {message}")]
21    Sops {
22        message: String,
23        exit_code: Option<i32>,
24    },
25
26    #[error("editor command failed: {message}")]
27    Editor { message: String },
28}
29
30impl InfraError {
31    /// Create an I/O error with context.
32    pub fn io(context: impl Into<String>, source: std::io::Error) -> Self {
33        Self::Io {
34            context: context.into(),
35            source,
36        }
37    }
38}
39
40/// Result type for infrastructure layer operations.
41pub type InfraResult<T> = Result<T, InfraError>;