"""Custom errors used in `versioned_collection`."""
[docs]classCollectionAlreadyInitialised(Exception):"""Raised when an initialised collection is tried to be reinitialised."""__DEFAULT_MESSAGE=("You tried to call `init()` on an already initialised versioned ""collection.")def__init__(self,message:str=__DEFAULT_MESSAGE)->None:super().__init__(message)
[docs]classInvalidOperation(Exception):"""Raised when an invalid operation is attempted on the collection."""def__init__(self,message:str)->None:super().__init__(message)
[docs]classInvalidCollectionVersion(Exception):"""Raised when trying to check out to a wrong collection version."""__DEFAULT_MESSAGE=("Version (version: {}, branch: {}) does not exist in the version tree.")def__init__(self,version:int,branch:str,message:str=__DEFAULT_MESSAGE)->None:message=message.format(version,branch)super().__init__(message)
[docs]classInvalidCollectionState(Exception):"""Raised when something terrible happens."""
[docs]classBranchNotFound(Exception):"""Raised when a branch could not be found."""def__init__(self,branch_name:str)->None:super().__init__(f"Branch '{branch_name}' does not exists!")
[docs]classAutoMergeFailedError(Exception):"""Raised when automatically merging two branches produces conflicts."""def__init__(self,branch:str)->None:super().__init__(f"Automatic merge failed. Fix conflicts for branch "f"{branch} and then register a new version. \n"f"For manually solving conflicts call `resolve_conflicts()`")