code_executor/
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
8    #[error("Runtime error: {message}")]
9    Runtime { message: String },
10
11    #[error("IO error: {0}")]
12    IO(#[from] std::io::Error),
13}
14
15impl From<std::string::FromUtf8Error> for Error {
16    fn from(error: std::string::FromUtf8Error) -> Self {
17        Error::IO(std::io::Error::other(error))
18    }
19}
20
21impl From<nix::errno::Errno> for Error {
22    fn from(value: nix::errno::Errno) -> Self {
23        Self::IO(std::io::Error::from(value))
24    }
25}
26
27impl From<libseccomp::error::SeccompError> for Error {
28    fn from(value: libseccomp::error::SeccompError) -> Self {
29        Self::IO(std::io::Error::other(value.to_string()))
30    }
31}