command_engine/shared/error.rs
1use std::fmt::{Display, Formatter};
2
3#[derive(Debug)]
4pub enum Error {
5 /// Instruction deserializer couldn't find Command caller in the input.
6 ///
7 /// Examples: <br>
8 /// - `input = ""`
9 /// - `input = "--o_arg"`
10 /// - `input = "--o_arg caller"`
11 InstructionMissingCaller,
12
13 /// Instruction deserializer received input that had SubArg before OArg
14 ///
15 /// (this shouldn't happen).
16 InstructionSubArgWithoutOArg,
17
18 /// Engine couldn't find a suitable Command for the received caller.
19 ///
20 /// Example:
21 /// ```pseudo
22 /// Engine = {
23 /// commands: ["echo", "dir", "ls"]
24 /// };
25 ///
26 /// Engine.execute("cd .."); // Error(EngineCommandNotFound)
27 /// ```
28 EngineCommandNotFound,
29}
30
31impl Display for Error {
32 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
33 write!(f, "{:?}", self)
34 }
35}
36
37impl std::error::Error for Error {}