Skip to main content

tkr_sandbox/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum SandboxError {
5    #[error("policy violation: {0}")]
6    PolicyViolation(String),
7    #[error("sandbox not supported on this platform")]
8    Unsupported,
9    #[error("backend failure: {0}")]
10    Backend(String),
11    #[error("io: {0}")]
12    Io(#[from] std::io::Error),
13}
14
15#[cfg(test)]
16mod tests {
17    use super::*;
18    #[test]
19    fn formats_policy_violation() {
20        let e = SandboxError::PolicyViolation("write to /etc denied".into());
21        assert_eq!(format!("{e}"), "policy violation: write to /etc denied");
22    }
23}