An error intended for display to humans. Use this exception type when the error is something the user can be expected to handle. If the error indicates a truly unexpected condition (i.e., a programming error), use a different exception type that will produce a backtrace instead.
| 158 | |
| 159 | |
| 160 | class UIError(Exception): |
| 161 | """An error intended for display to humans. |
| 162 | |
| 163 | Use this exception type when the error is something the user can be expected |
| 164 | to handle. If the error indicates a truly unexpected condition (i.e., a |
| 165 | programming error), use a different exception type that will produce a |
| 166 | backtrace instead. |
| 167 | |
| 168 | Attributes: |
| 169 | hint: An optional hint to display alongside the error message. |
| 170 | """ |
| 171 | |
| 172 | def __init__(self, message: str, hint: str | None = None): |
| 173 | super().__init__(message) |
| 174 | self.hint = hint |
| 175 | |
| 176 | def set_hint(self, hint: str) -> None: |
| 177 | """Attaches a hint to the error. |
| 178 | |
| 179 | This method will overwrite the existing hint, if any. |
| 180 | """ |
| 181 | self.hint = hint |
| 182 | |
| 183 | |
| 184 | class CommandFailureCausedUIError(UIError): |
no outgoing calls