[docs]classAO3Exception(Exception):"""Base exception for AO3."""
[docs]classHTTPException(AO3Exception):"""Exception that's raised when something goes wrong during an HTTP request. Parameters ---------- response: :class:`aiohttp.ClientResponse` The HTTP response that caused this error. message: :class:`str` The given message accompanying this error to be added to the error display. Attributes ---------- response: :class:`aiohttp.ClientResponse` The HTTP response that caused this error. status: :class:`int` The HTTP status or code of the response. text: :class:`str` The message accompanying this error that will be part of the error display. """def__init__(self,response:ClientResponse,message:str|None=None)->None:self.response=responseself.status=response.statusself.text=messageor""new_message=f"{response.status}{response.reasonor''}"ifself.text:new_message+=f": {self.text}"super().__init__(new_message)
[docs]classLoginFailure(AO3Exception):"""Exception that's raised when an attempt to log in to AO3 fails."""
[docs]classUnloadedError(AO3Exception):"""Exception that's raised when the content of an AO3 object hasn't been loaded, but accessing it was attempted."""def__init__(self,message:str|None=None)->None:message=messageor"._element for this object was never loaded, and thus has nothing to pull from."super().__init__(message)
[docs]classAuthError(AO3Exception):"""Exception that's raised when the authentication token for the AO3 session is invalid."""def__init__(self,message:str|None=None)->None:message=messageor("Valid authenticity token for this model can't be found. If you're sure you don't need to be logged in to ""perform this action, try again after reloading the model.")super().__init__(message)
[docs]classPseudError(AO3Exception):"""Exception that's raised when a pseud's ID couldn't be found."""def__init__(self,pseud:str|None=None)->None:actual_pseud=f'pseud "{pseud}"'ifpseudelse"your default pseud"message=f"The ID for {actual_pseud} could not be found."super().__init__(message)
[docs]classKudoError(AO3Exception):"""Exception that's raised when attempting to give a kudo fails."""def__init__(self,message:str|None=None)->None:message=messageor"Unknown error coccured while attempting to give kudos to this item."super().__init__(message)
[docs]classBookmarkError(AO3Exception):"""Exception that's raised when attempting to create or access a bookmark fails."""def__init__(self,message:str|None=None)->None:message=messageor"Unknown error coccured while attempting to bookmark this item."super().__init__(message)
[docs]classSubscribeError(AO3Exception):"""Exception that's raised when attempting to create or access a subscription fails."""def__init__(self,message:str|None=None)->None:message=messageor"Unknown error coccured while attempting to subscribe to this item."super().__init__(message)
[docs]classCollectError(AO3Exception):"""Exception that's raised when attempting to invite a work to a collection fails."""def__init__(self,message:str|None=None)->None:message=messageor"Unknown error coccured while attempting to collect this item."super().__init__(message)
[docs]classInvalidURLError(AO3Exception):"""Exception that's raised when an invalid AO3 url was passed in."""
[docs]classDownloadError(AO3Exception):"""Exception that's raised when downloading an AO3 work fails."""
[docs]classDuplicateCommentError(AO3Exception):"""Exception that's raised when attempting to post a comment that already exists."""