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}
9
10impl ThreadError {
11    pub fn as_str(self) -> &'static str {
12        match self {
13            ThreadError::MaxThreadsReached => "Maximum number of threads reached",
14            ThreadError::InvalidThreadId => "Invalid thread ID provided",
15            ThreadError::ThreadNotRunnable => "Thread is not in a runnable state",
16            ThreadError::StackOverflow => "Stack overflow detected",
17            ThreadError::SchedulerFull => "Scheduler queue is full",
18        }
19    }
20}
21
22pub type ThreadResult<T> = Result<T, ThreadError>;