mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 10:26:21 +00:00
48 lines
1.1 KiB
Rust
48 lines
1.1 KiB
Rust
use std::{
|
|
error::Error,
|
|
fmt::{Debug, Display, Formatter},
|
|
sync::PoisonError,
|
|
};
|
|
|
|
use crate::scheduler::scheduler_error::SchedulerError::MutexPoison;
|
|
|
|
pub enum SchedulerError {
|
|
IdNotFound,
|
|
IdAlreadyRunning,
|
|
MutexPoison(String),
|
|
}
|
|
|
|
impl<T> From<PoisonError<T>> for SchedulerError {
|
|
fn from(value: PoisonError<T>) -> Self {
|
|
MutexPoison(value.to_string())
|
|
}
|
|
}
|
|
|
|
impl Debug for SchedulerError {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{}", self)
|
|
}
|
|
}
|
|
|
|
impl Display for SchedulerError {
|
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
|
write!(
|
|
f,
|
|
"{}",
|
|
match self {
|
|
SchedulerError::IdNotFound => {
|
|
"SchedulerError::IdNotFound".to_string()
|
|
}
|
|
SchedulerError::IdAlreadyRunning => {
|
|
"SchedulerError::IdAlreadyRunning".to_string()
|
|
}
|
|
MutexPoison(str) => {
|
|
format!("SchedulerError::MutexPoison: {}", str)
|
|
}
|
|
}
|
|
)
|
|
}
|
|
}
|
|
|
|
impl Error for SchedulerError {}
|