dockerfile_parser_rs/
error.rs

1use std::fmt;
2
3#[derive(Debug)]
4pub enum ParseError {
5    BadNumberOfArguments(String),
6    FileError(String),
7    MissingArgument(String),
8    SyntaxError(String),
9    UnknownInstruction(String),
10}
11
12impl fmt::Display for ParseError {
13    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
14        match self {
15            Self::BadNumberOfArguments(msg) => write!(f, "Wrong number of arguments: {msg}"),
16            Self::FileError(msg) => write!(f, "File error: {msg}"),
17            Self::MissingArgument(msg) => write!(f, "Missing argument: {msg}"),
18            Self::SyntaxError(msg) => write!(f, "Syntax error: {msg}"),
19            Self::UnknownInstruction(msg) => write!(f, "Unknown instruction: {msg}"),
20        }
21    }
22}