"""Custom exception hierarchy for CSS Mod Manager.

Every exception raised by project-specific logic (as opposed to standard
library errors like `OSError` or `json.JSONDecodeError`) inherits from
`CoreError`. This lets calling code -- a Flask route, a batch-install loop --
catch `CoreError` to handle *expected* domain/validation failures uniformly,
while genuine bugs (`AttributeError`, `KeyError` from a coding mistake) are
left to propagate instead of being silently swallowed.
"""


class CoreError(Exception):
    """Base class for all custom exceptions raised by this project."""


class ValidationError(CoreError):
    """Raised when input data (names, options, values) fails validation rules."""


class UMCParserError(CoreError):
    """Raised when a UMC (KeyValues) file cannot be parsed."""


class CategoryManagerError(CoreError):
    """Base class for errors related to category/map bookkeeping in UMC data."""


class CategoryAlreadyExists(CategoryManagerError):
    """Raised when trying to create a category that already exists."""


class CategoryNotFound(CategoryManagerError):
    """Raised when referencing a category that does not exist."""


class MapAlreadyExists(CategoryManagerError):
    """Raised when trying to add a map that is already present in a category."""


class MapNotFound(CategoryManagerError):
    """Raised when referencing a map that does not exist in a category."""


class MapInstallerError(CoreError):
    """Raised when the physical installation of a .bsp file fails."""


class CompressionError(CoreError):
    """Raised when bz2 compression of a map file fails."""


class InstallServiceError(CoreError):
    """Raised when the map installation workflow fails (validation or transaction)."""


class DeleteServiceError(CoreError):
    """Raised when a mod/map deletion workflow fails (validation or transaction)."""
