1pub type Result<T> = std::result::Result<T, Error>;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5 #[error("scheduler error: {0}")]
6 Scheduler(String),
7
8 #[error("executor error: {0}")]
9 Executor(String),
10
11 #[error("config error: {0}")]
12 Config(String),
13
14 #[error("runtime not initialized")]
15 NotInitialized,
16
17 #[error("already initialized")]
18 AlreadyInitialized,
19
20 #[error("worker panic: {0}")]
21 WorkerPanic(String),
22
23 #[error("task failed: {0}")]
24 TaskFailed(String),
25
26 #[cfg(feature = "gpu")]
27 #[error("GPU error: {0}")]
28 Gpu(String),
29
30 #[cfg(feature = "async")]
31 #[error("async error: {0}")]
32 Async(String),
33
34 #[cfg(feature = "numa")]
35 #[error("NUMA error: {0}")]
36 Numa(String),
37
38 #[error("I/O error: {0}")]
39 Io(#[from] std::io::Error),
40
41 #[error("{0}")]
42 Other(String),
43}
44
45impl Error {
46 pub fn scheduler<S: Into<String>>(msg: S) -> Self {
47 Error::Scheduler(msg.into())
48 }
49
50 pub fn executor<S: Into<String>>(msg: S) -> Self {
51 Error::Executor(msg.into())
52 }
53
54 pub fn config<S: Into<String>>(msg: S) -> Self {
55 Error::Config(msg.into())
56 }
57
58 #[cfg(feature = "gpu")]
59 pub fn gpu<S: Into<String>>(msg: S) -> Self {
60 Error::Gpu(msg.into())
61 }
62
63 #[cfg(feature = "async")]
64 pub fn async_error<S: Into<String>>(msg: S) -> Self {
65 Error::Async(msg.into())
66 }
67
68 #[cfg(feature = "telemetry")]
69 pub fn telemetry<S: Into<String>>(msg: S) -> Self {
70 Error::Other(format!("telemetry: {}", msg.into()))
71 }
72}