use nix::errno::Errno;
#[derive(Debug)]
pub struct CapsError(pub Errno);
impl std::fmt::Display for CapsError {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "caps error: {}", self.0)
}
}
impl std::error::Error for CapsError {}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_capserror_1() {
let e = CapsError(Errno::EPERM);
let s = e.to_string();
assert!(s.contains("caps error"));
}
#[test]
fn test_capserror_2() {
let e = CapsError(Errno::EINVAL);
let s = e.to_string();
assert!(s.contains("caps error"));
}
#[test]
fn test_capserror_3() {
let e = CapsError(Errno::ENOTSUP);
let s = e.to_string();
assert!(!s.is_empty());
}
}