blob: 3053880228017570f33581635c8c8f37e1e3f658 (
plain)
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
54
55
56
|
namespace marlin.core.util;
/// <summary>
/// Base exception for all variable expansion errors
/// </summary>
public class VariableExpansionException(string message) : Exception(message);
/// <summary>
/// Thrown when a variable is referenced but not found in the variables dictionary
/// </summary>
public class VariableNotFoundException : VariableExpansionException
{
public string VariableName { get; }
public VariableNotFoundException(string variableName)
: base($"Variable '{variableName}' not found")
{
this.VariableName = variableName;
}
}
/// <summary>
/// Thrown when an expression has invalid syntax or cannot be parsed
/// </summary>
public class InvalidExpressionException : VariableExpansionException
{
public string Expression { get; }
public InvalidExpressionException(string expression)
: base($"Invalid expression '{expression}'")
{
this.Expression = expression;
}
public InvalidExpressionException(string expression, string reason)
: base($"Invalid expression '{expression}': {reason}")
{
this.Expression = expression;
}
}
/// <summary>
/// Thrown when braces are not properly matched or escaped
/// </summary>
public class UnmatchedBraceException : VariableExpansionException
{
public int Position { get; }
public string Remainder { get; }
public UnmatchedBraceException(string message, int position, string remainder)
: base(message)
{
this.Position = position;
this.Remainder = remainder;
}
}
|