"""
exception raise by this package
"""
# Copyright (c) 2018-2021 Trim21 <i@trim21.me>
# Copyright (c) 2008-2014 Erik Svensson <erik.public@gmail.com>
# Licensed under the MIT license.
from typing import Optional
import requests.exceptions
from requests.models import Response
[docs]class TransmissionError(Exception):
"""
This exception is raised when there has occurred an error related to
communication with Transmission.
"""
[docs] def __init__(self, message: str = "", original: Optional[Response] = None):
super().__init__()
self.message = message
self.original = original
def __str__(self) -> str:
if self.original:
original_name = type(self.original).__name__
return f'{self.message} Original exception: {original_name}, "{self.original}"'
return self.message
[docs]class TransmissionAuthError(TransmissionError):
"""Raised when username or password is incorrect"""
[docs]class TransmissionConnectError(TransmissionError, requests.exceptions.ConnectionError):
"""raised when client can't connect to transmission daemon"""
[docs]class TransmissionTimeoutError(TransmissionConnectError, requests.exceptions.Timeout):
"""Timeout"""
[docs]class TransmissionVersionError(TransmissionError):
"""transmission version is too lower to support some feature"""