[docs]classActionFailure(Exception):"""Exception raised when an action fails to execute successfully."""def__init__(self,message:str,action_name:str|None=None)->None:self.message=messageself.action_name=action_namesuper().__init__(self.message)defset_action_name(self,action_name:str)->None:"""Set the name of the action that failed."""self.action_name=action_name
[docs]def__str__(self)->str:"""Return a formatted error message."""return(f"Action failure in {self.action_name}: {self.message}"ifself.action_nameelsef"Action failure: {self.message}")
[docs]classAssetMisconfiguration(ActionFailure):"""Exception raised when an asset is misconfigured."""
[docs]def__str__(self)->str:"""Return a formatted error message."""return(f"Asset misconfiguration in {self.action_name}: {self.message}"ifself.action_nameelsef"Asset misconfiguration: {self.message}")
[docs]classSoarAPIError(ActionFailure):"""Exception raised when there is an error with the SOAR REST API."""
[docs]def__str__(self)->str:"""Return a formatted error message."""return(f"SOAR REST API error in {self.action_name}: {self.message}"ifself.action_nameelsef"SOAR REST API error: {self.message}")
[docs]classActionRegistrationError(Exception):"""Exception raised when there is an error registering an action."""def__init__(self,action:str)->None:self.action=actionsuper().__init__(f"Error registering action: {action}")
classAppContextRequired(Exception):"""Exception raised when trying to access certain features outside the proper context."""def__init__(self)->None:super().__init__("This feature is only available in the context of an action run or webhook handler.")__all__=["ActionFailure","ActionRegistrationError","AssetMisconfiguration","SoarAPIError",]