Initial upload: config-converter-cli v1.0.0
This commit is contained in:
71
configconverter/exceptions.py
Normal file
71
configconverter/exceptions.py
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user