1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
"""
Global Tusclient exception and warning classes.
"""
class TusCommunicationError(Exception):
"""
Should be raised when communications with tus-server behaves
unexpectedly.
:Attributes:
- message (str):
Main message of the exception
- status_code (int):
Status code of response indicating an error
- response_content (str):
Content of response indicating an error
:Constructor Args:
- message (Optional[str])
- status_code (Optional[int])
- response_content (Optional[str])
"""
def __init__(self, message, status_code=None, response_content=None):
default_message = "Communication with tus server failed with status {}".format(
status_code
)
message = message or default_message
super(TusCommunicationError, self).__init__(message)
self.status_code = status_code
self.response_content = response_content
class TusUploadFailed(TusCommunicationError):
"""Should be raised when an attempted upload fails"""
|