1use tokio::time::error::Elapsed;
2
3pub type Result<T> = std::result::Result<T, Error>;
4
5#[derive(Debug, thiserror::Error)]
6pub enum Error {
7 #[error("Compilation error: {message}")]
8 Compilation { message: String },
9
10 #[error("Runtime error: {message}")]
11 Runtime { message: String },
12
13 #[error("The process exceed time limit")]
14 Timeout,
15
16 #[error("IO error: {0}")]
17 IO(#[from] std::io::Error),
18}
19
20impl From<std::string::FromUtf8Error> for Error {
21 fn from(error: std::string::FromUtf8Error) -> Self {
22 Error::IO(std::io::Error::other(error))
23 }
24}
25
26impl From<libseccomp::error::SeccompError> for Error {
27 fn from(error: libseccomp::error::SeccompError) -> Self {
28 Self::IO(std::io::Error::other(error.to_string()))
29 }
30}
31
32impl From<cgroups_rs::error::Error> for Error {
33 fn from(error: cgroups_rs::error::Error) -> Self {
34 Self::IO(std::io::Error::other(error))
35 }
36}
37
38impl From<Elapsed> for Error {
39 fn from(_: Elapsed) -> Self {
40 Self::Timeout
41 }
42}