From 6ab670fc8ab3fdfb041e3fd338a98644597b87be Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 1 Feb 2026 22:26:06 +0000 Subject: [PATCH] Initial upload: config-converter-cli v1.0.0 --- configconverter/exceptions.py | 71 +++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 configconverter/exceptions.py diff --git a/configconverter/exceptions.py b/configconverter/exceptions.py new file mode 100644 index 0000000..10d92d5 --- /dev/null +++ b/configconverter/exceptions.py @@ -0,0 +1,71 @@ +"""Custom exceptions for config-converter-cli.""" + +from typing import Any, Optional + + +class ConfigConverterError(Exception): + """Base exception for config converter errors.""" + + def __init__(self, message: str, details: Optional[dict] = None): + super().__init__(message) + self.message = message + self.details = details or {} + + +class ParseError(ConfigConverterError): + """Raised when parsing fails due to invalid syntax.""" + + def __init__( + self, + message: str, + line_number: Optional[int] = None, + column: Optional[int] = None, + context: Optional[str] = None, + ): + details = {} + if line_number is not None: + details["line_number"] = line_number + if column is not None: + details["column"] = column + if context is not None: + details["context"] = context + super().__init__(message, details) + self.line_number = line_number + self.column = column + self.context = context + + +class InvalidFormatError(ConfigConverterError): + """Raised when the input format cannot be determined or is unsupported.""" + + pass + + +class UnsupportedConversionError(ConfigConverterError): + """Raised when a conversion direction is not supported.""" + + pass + + +class FileNotFoundError(ConfigConverterError): + """Raised when a file cannot be found.""" + + pass + + +class QueryError(ConfigConverterError): + """Raised when a JMESPath query fails.""" + + pass + + +class ValidationError(ConfigConverterError): + """Raised when validation fails.""" + + pass + + +class IndentationError(ConfigConverterError): + """Raised when indentation is invalid.""" + + pass