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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
use alloc::format;
use uefi::proto::console::text::Color;
use crate::Toolkit;
#[derive(Copy, Clone)]
pub enum Error {
E01,
E02,
E03,
E04,
E05,
E06,
E07,
E08,
E09,
E10,
E11,
E12,
E13
}
impl Error {
fn description(&self) -> &str {
match self {
Error::E01 => "An internal undocumented system error has occurred.",
Error::E02 => "The requested command could not be found.",
Error::E03 => "Too few arguments were provided to this command.",
Error::E04 => "The requested file or directory could not be found.",
Error::E05 => "Unable to go up one level from the root directory.",
Error::E06 => "No command name could be found in the input.",
Error::E07 => "Unexpected end of line: quotes do not match.",
Error::E08 => "Too many arguments were provided to this command.",
Error::E09 => "The requested file is not a directory.",
Error::E10 => "The requested file already exists.",
Error::E11 => "The directory to affect is not empty.",
Error::E12 => "The requested file is a directory.",
Error::E13 => "Input/output error occurred while reading the file."
//_ => "Unknown error."
}
}
fn code (&self) -> u32 {
(*self as u32) + 1
}
}
pub fn display_error(tk: &mut Toolkit, error: Error) {
tk.color(Color::Black, Color::Red);
tk.print(&format!("Error {}:", error.code()));
tk.color(Color::LightRed, Color::Black);
tk.println(&format!(" {}", error.description()));
tk.println("");
}
|