"""Custom exceptions thrown in qnexus usage."""fromtypingimportOptional
[docs]classAuthenticationError(Exception):"Raised when there is an issue authenticating with the Nexus API."
[docs]classResourceFetchFailed(Exception):""" Raised when a resource cannot be fetched from the platform to be read, or when expected data wasn't found on an object. """def__init__(self,message:str,status_code:Optional[int]=None)->None:self.message=messageself.status_code=status_codeself.err=("Failed to fetch resource with status code: "f"{self.status_code}, message: {self.message}")super().__init__(self.err)
[docs]classZeroMatches(Exception):"""Raised when a ``get`` call finds no matches."""
[docs]classNoUniqueMatch(Exception):"""Raised when a ``get`` call finds more than one match."""
[docs]classJobError(Exception):"""Raised when a Nexus Job has errored."""
[docs]classResourceCreateFailed(Exception):"""Raised when a resource couldn't be created on the platform."""def__init__(self,message:str,status_code:Optional[int]=None)->None:self.message=messageself.status_code=status_codeself.err=("Failed to create resource with status code: "f"{self.status_code}, message: {self.message}")super().__init__(self.err)
[docs]classResourceDeleteFailed(Exception):"""Raised when a resource couldn't be deleted on the platform."""def__init__(self,message:str,status_code:Optional[int]=None)->None:self.message=messageself.status_code=status_codeself.err=("Failed to delete resource with status code: "f"{self.status_code}, message: {self.message}")super().__init__(self.err)
[docs]classResourceUpdateFailed(Exception):"""Raised when a resource cannot be updated on the platform."""def__init__(self,message:str,status_code:Optional[int]=None)->None:self.message=messageself.status_code=status_codeself.err=("Failed to update resource with status code: "f"{self.status_code}, message: {self.message}")super().__init__(self.err)