Executable/
Error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
use core::result::Result;
use std::fmt::Display;

pub type Result_type<T> = Result<T, Error_type>;

#[derive(Debug, Clone)]
pub enum Error_type {
    File_system(File_system::Error_type),
    Task(Task::Error_type),
    Failed_to_get_main_function,
    Invalid_stack_size,
    Permission_denied,
}

impl Display for Error_type {
    fn fmt(&self, Formatter: &mut core::fmt::Formatter) -> core::fmt::Result {
        match self {
            Error_type::File_system(Error) => write!(Formatter, "{}", Error),
            Error_type::Task(Error) => write!(Formatter, "{}", Error),
            Error_type::Failed_to_get_main_function => {
                write!(Formatter, "Failed to get main function")
            }
            Error_type::Invalid_stack_size => write!(Formatter, "Invalid stack size"),
            Error_type::Permission_denied => write!(Formatter, "Permission denied"),
        }
    }
}

impl From<File_system::Error_type> for Error_type {
    fn from(Error: File_system::Error_type) -> Self {
        Error_type::File_system(Error)
    }
}

impl From<Task::Error_type> for Error_type {
    fn from(Error: Task::Error_type) -> Self {
        Error_type::Task(Error)
    }
}