Module resonitepy.exceptions
This module define the Exceptions classes use by this package.
Expand source code
"""
This module define the Exceptions classes use by this package.
"""
import requests
import json
class ResoniteException(Exception):
pass
class ResoniteAPIException(ResoniteException):
def __init__(self, req, message = None):
if not message:
message = "[" + str(req.status_code) + "] API response: " + req.text
message += "\n HEADERS:\n"
message += str(req.headers)
super().__init__(message)
self.status_code = req.status_code
try:
self.json = req.json()
except json.decoder.JSONDecodeError:
self.json = {}
class InvalidCredentials(ResoniteException):
pass
class NoTokenError(ResoniteException):
pass
class FolderNotFound(ResoniteException):
pass
class InvalidToken(ResoniteException):
pass
class ResoniteParseError(ResoniteException):
""" Raised when an API response doesn't match the expected class. """
def __init__(self, data_class: type, data, error):
self.data_class = data_class
self.data = data
self.error = error
super().__init__(f"Failed to parse {data_class.__name__}: {error}")
class ResoniteHubException(ResoniteException):
""" Raised when a hub invocation fails, times out, or the hub is not connected.
"""
pass
Classes
class FolderNotFound (*args, **kwargs)-
Common base class for all non-exit exceptions.
Expand source code
class FolderNotFound(ResoniteException): passAncestors
- ResoniteException
- builtins.Exception
- builtins.BaseException
class InvalidCredentials (*args, **kwargs)-
Common base class for all non-exit exceptions.
Expand source code
class InvalidCredentials(ResoniteException): passAncestors
- ResoniteException
- builtins.Exception
- builtins.BaseException
class InvalidToken (*args, **kwargs)-
Common base class for all non-exit exceptions.
Expand source code
class InvalidToken(ResoniteException): passAncestors
- ResoniteException
- builtins.Exception
- builtins.BaseException
class NoTokenError (*args, **kwargs)-
Common base class for all non-exit exceptions.
Expand source code
class NoTokenError(ResoniteException): passAncestors
- ResoniteException
- builtins.Exception
- builtins.BaseException
class ResoniteAPIException (req, message=None)-
Common base class for all non-exit exceptions.
Expand source code
class ResoniteAPIException(ResoniteException): def __init__(self, req, message = None): if not message: message = "[" + str(req.status_code) + "] API response: " + req.text message += "\n HEADERS:\n" message += str(req.headers) super().__init__(message) self.status_code = req.status_code try: self.json = req.json() except json.decoder.JSONDecodeError: self.json = {}Ancestors
- ResoniteException
- builtins.Exception
- builtins.BaseException
class ResoniteException (*args, **kwargs)-
Common base class for all non-exit exceptions.
Expand source code
class ResoniteException(Exception): passAncestors
- builtins.Exception
- builtins.BaseException
Subclasses
class ResoniteHubException (*args, **kwargs)-
Raised when a hub invocation fails, times out, or the hub is not connected.
Expand source code
class ResoniteHubException(ResoniteException): """ Raised when a hub invocation fails, times out, or the hub is not connected. """ passAncestors
- ResoniteException
- builtins.Exception
- builtins.BaseException
class ResoniteParseError (data_class: type, data, error)-
Raised when an API response doesn't match the expected class.
Expand source code
class ResoniteParseError(ResoniteException): """ Raised when an API response doesn't match the expected class. """ def __init__(self, data_class: type, data, error): self.data_class = data_class self.data = data self.error = error super().__init__(f"Failed to parse {data_class.__name__}: {error}")Ancestors
- ResoniteException
- builtins.Exception
- builtins.BaseException