namespace marlin.core.util;
///
/// Base exception for all variable expansion errors
///
public class VariableExpansionException(string message) : Exception(message);
///
/// Thrown when a variable is referenced but not found in the variables dictionary
///
public class VariableNotFoundException : VariableExpansionException
{
public string VariableName { get; }
public VariableNotFoundException(string variableName)
: base($"Variable '{variableName}' not found")
{
this.VariableName = variableName;
}
}
///
/// Thrown when an expression has invalid syntax or cannot be parsed
///
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;
}
}
///
/// Thrown when braces are not properly matched or escaped
///
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;
}
}