preemptive_threads/
error.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq)]
2pub enum ThreadError {
3    MaxThreadsReached,
4    InvalidThreadId,
5    ThreadNotRunnable,
6    StackOverflow,
7    SchedulerFull,
8    NotRunning,
9    NotImplemented,
10    MemoryAllocationFailed,
11    InvalidArgument,
12    DeadlockDetected,
13    ResourceExhausted,
14}
15
16impl ThreadError {
17    pub fn as_str(self) -> &'static str {
18        match self {
19            ThreadError::MaxThreadsReached => "Maximum number of threads reached",
20            ThreadError::InvalidThreadId => "Invalid thread ID provided",
21            ThreadError::ThreadNotRunnable => "Thread is not in a runnable state",
22            ThreadError::StackOverflow => "Stack overflow detected",
23            ThreadError::SchedulerFull => "Scheduler queue is full",
24            ThreadError::NotRunning => "Thread is not running",
25            ThreadError::NotImplemented => "Feature not implemented",
26            ThreadError::MemoryAllocationFailed => "Memory allocation failed",
27            ThreadError::InvalidArgument => "Invalid argument provided",
28            ThreadError::DeadlockDetected => "Deadlock detected",
29            ThreadError::ResourceExhausted => "System resources exhausted",
30        }
31    }
32}
33
34pub type ThreadResult<T> = Result<T, ThreadError>;