Module pyControl4.error_handling
Handles errors received from the Control4 API.
Functions
def check_response_for_error(response_text: str) ‑> None-
Expand source code
def check_response_for_error(response_text: str) -> None: """Checks a string response from the Control4 API for error codes. Parameters: `response_text` - JSON or XML response from Control4, as a string. """ response_format = _check_response_format(response_text) if response_format == "JSON": dictionary = json.loads(response_text) else: # XML dictionary = xmltodict.parse(response_text) error_info = _extract_error_info(dictionary) if error_info: _raise_error(error_info, response_text)Checks a string response from the Control4 API for error codes.
Parameters
response_text- JSON or XML response from Control4, as a string.
Classes
class BadCredentials (message: str)-
Expand source code
class BadCredentials(Unauthorized): """Raised when provided credentials are incorrect."""Raised when provided credentials are incorrect.
Ancestors
- Unauthorized
- C4Exception
- builtins.Exception
- builtins.BaseException
class BadToken (message: str)-
Expand source code
class BadToken(Unauthorized): """Raised when director bearer token is invalid."""Raised when director bearer token is invalid.
Ancestors
- Unauthorized
- C4Exception
- builtins.Exception
- builtins.BaseException
class C4Exception (message: str)-
Expand source code
class C4Exception(Exception): """Base error for pyControl4.""" def __init__(self, message: str) -> None: self.message = messageBase error for pyControl4.
Ancestors
- builtins.Exception
- builtins.BaseException
Subclasses
class InvalidCategory (message: str)-
Expand source code
class InvalidCategory(C4Exception): """Raised when an invalid category is provided when calling `pyControl4.director.C4Director.get_all_items_by_category`."""Raised when an invalid category is provided when calling
C4Director.get_all_items_by_category().Ancestors
- C4Exception
- builtins.Exception
- builtins.BaseException
class NotFound (message: str)-
Expand source code
class NotFound(C4Exception): """Raised when a 404 response is received from the Control4 API. Occurs when the requested controller, etc. could not be found."""Raised when a 404 response is received from the Control4 API. Occurs when the requested controller, etc. could not be found.
Ancestors
- C4Exception
- builtins.Exception
- builtins.BaseException
-
Expand source code
class Unauthorized(C4Exception): """Raised when unauthorized, but no other recognized details are provided. Occurs when token is invalid."""Raised when unauthorized, but no other recognized details are provided. Occurs when token is invalid.
Ancestors
- C4Exception
- builtins.Exception
- builtins.BaseException
Subclasses