Skip to main content

zerobox_linux_sandbox/
error.rs

1use std::io;
2use thiserror::Error;
3
4pub type Result<T> = std::result::Result<T, CodexErr>;
5
6#[derive(Error, Debug)]
7pub enum SandboxErr {
8    #[cfg(target_os = "linux")]
9    #[error("seccomp setup error")]
10    SeccompInstall(#[from] seccompiler::Error),
11
12    #[cfg(target_os = "linux")]
13    #[error("seccomp backend error")]
14    SeccompBackend(#[from] seccompiler::BackendError),
15
16    #[error("command was killed by a signal")]
17    Signal(i32),
18
19    #[error("Landlock was not able to fully enforce all sandbox rules")]
20    LandlockRestrict,
21}
22
23#[derive(Error, Debug)]
24pub enum CodexErr {
25    #[error("sandbox error: {0}")]
26    Sandbox(#[from] SandboxErr),
27
28    #[error("unsupported operation: {0}")]
29    UnsupportedOperation(String),
30
31    #[error("Fatal error: {0}")]
32    Fatal(String),
33
34    #[error(transparent)]
35    Io(#[from] io::Error),
36
37    #[cfg(target_os = "linux")]
38    #[error(transparent)]
39    LandlockRuleset(#[from] landlock::RulesetError),
40
41    #[cfg(target_os = "linux")]
42    #[error(transparent)]
43    LandlockPathFd(#[from] landlock::PathFdError),
44}