srcsrv/
errors.rs

1/// An enum for errors that occur during stream parsing.
2#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
3#[non_exhaustive]
4pub enum ParseError {
5    #[error("The srcsrv stream is not valid utf-8.")]
6    InvalidUtf8,
7
8    #[error("The srcsrv stream ended unexpectedly.")]
9    UnexpectedEof,
10
11    #[error("Version {0} is not a recognized srcsrv stream version.")]
12    UnrecognizedVersion(String),
13
14    #[error("The VERSION ini variable is missing.")]
15    MissingVersion,
16
17    #[error("Could not find the ini section in the srcsrv stream.")]
18    MissingIniSection,
19
20    #[error("Could not find the variables section in the srcsrv stream.")]
21    MissingVariablesSection,
22
23    #[error("The SRCSRVTRG field was missing. This is a required field.")]
24    MissingSrcSrvTrgField,
25
26    #[error("Could not find the source files section in the srcsrv stream.")]
27    MissingSourceFilesSection,
28
29    #[error("Could not find the end marker line in theh srcsrv stream.")]
30    MissingTerminationLine,
31
32    #[error("Missing = in a variable line in the srcsrv stream.")]
33    MissingEquals,
34
35    #[error("Missing closing % in srcsrv variable use.")]
36    MissingPercent,
37
38    #[error("Expected ( after {0} function in srcsrv variable.")]
39    MissingOpeningParen(String),
40
41    #[error("Could not find closing ) for {0} function in srcsrv variable.")]
42    MissingClosingParen(String),
43}
44
45/// An enum for errors that can occur when looking up the SourceRetrievalMethod
46/// for a file, and when evaluating the variables.
47#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
48#[non_exhaustive]
49pub enum EvalError {
50    #[error("Encountered recursion while evaluating srcsrv variable {0}.")]
51    Recursion(String),
52
53    #[error("Could not resolve srcsrv variable name {0}.")]
54    UnknownVariable(String),
55}