diff options
Diffstat (limited to 'src/marlin.core/util/VariableExpansionException.cs')
| -rw-r--r-- | src/marlin.core/util/VariableExpansionException.cs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/marlin.core/util/VariableExpansionException.cs b/src/marlin.core/util/VariableExpansionException.cs new file mode 100644 index 0000000..3053880 --- /dev/null +++ b/src/marlin.core/util/VariableExpansionException.cs @@ -0,0 +1,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; + } +} |
