judge_framework/backend/
error.rs

1pub type Result<T> = std::result::Result<T, Error>;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    #[error("Compilation error: {message}")]
6    Compilation { message: String },
7    #[error("IO error: {0}")] 
8    IO(#[from] std::io::Error),
9}
10
11impl From<std::string::FromUtf8Error> for Error {
12    fn from(error: std::string::FromUtf8Error) -> Self {
13        Error::IO(std::io::Error::other(error))
14    }
15}
16
17impl From<nix::errno::Errno> for Error {
18    fn from(value: nix::errno::Errno) -> Self {
19        Self::IO(std::io::Error::from(value))
20    }
21}
22
23impl From<libseccomp::error::SeccompError> for Error {
24    fn from(value: libseccomp::error::SeccompError) -> Self {
25        Self::IO(std::io::Error::other(value.to_string()))
26    }
27}