wg_utilities.exceptions
Custom exception types.
BadDefinitionError
Bases: WGUtilitiesError
Raised when some kind of definition is invalid.
Source code in wg_utilities/exceptions/_exception.py
19 20 |
|
BadUsageError
Bases: WGUtilitiesError
Raised when something is used incorrectly.
Source code in wg_utilities/exceptions/_exception.py
23 24 |
|
NotFoundError
Bases: WGUtilitiesError
Raised when something is not found.
Source code in wg_utilities/exceptions/_exception.py
27 28 |
|
WGUtilitiesError
Bases: Exception
Base class for all exceptions raised by wg_utilities.
Source code in wg_utilities/exceptions/_exception.py
9 10 11 12 13 14 15 16 |
|
subclasses()
cached
classmethod
Return a list of all subclasses of this error, cached for performance.
Source code in wg_utilities/exceptions/_exception.py
12 13 14 15 16 |
|
on_exception(exception_callback=send_exception_to_home_assistant, *, raise_after_callback=True, logger=None, ignore_exception_types=None, default_return_value=None, _suppress_ignorant_warnings=None)
Allow simple cover-all exception handler callback behaviour.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exception_callback |
Callable
|
callback function to process the exception |
send_exception_to_home_assistant
|
raise_after_callback |
bool
|
raise the exception after the callback has run |
True
|
logger |
Logger
|
optional logger for logging the exception |
None
|
ignore_exception_types |
Iterable[type[Exception]]
|
optional iterable of exception types to ignore |
None
|
default_return_value |
Any
|
optional default return value for the decorated function |
None
|
_suppress_ignorant_warnings |
bool
|
optional flag to suppress warnings about ignoring exception types |
None
|
Returns:
Name | Type | Description |
---|---|---|
Callable |
Callable[[Any], Any]
|
the actual decorator |
Source code in wg_utilities/exceptions/_deprecated.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
send_exception_to_home_assistant(exc)
Format an exception and send useful info to Home Assistant.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
exc |
Exception
|
the exception being handled |
required |
Raises:
Type | Description |
---|---|
ValueError
|
if the HA_LOG_ENDPOINT isn't set |
Exception
|
if posting the exception to HA fails, then an exception is raised |
Source code in wg_utilities/exceptions/_deprecated.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|