Attributes ---------- message: :class:`str` The error message. severity: :enum:`Severity` The severity of the error. cause: :class:`str` The cause of the error. cause_stacktrace: :class:`str` The stacktrace for the error. May be empty
| 272 | |
| 273 | |
| 274 | class LoadResultError: |
| 275 | """ |
| 276 | Attributes |
| 277 | ---------- |
| 278 | message: :class:`str` |
| 279 | The error message. |
| 280 | severity: :enum:`Severity` |
| 281 | The severity of the error. |
| 282 | cause: :class:`str` |
| 283 | The cause of the error. |
| 284 | cause_stacktrace: :class:`str` |
| 285 | The stacktrace for the error. |
| 286 | May be empty if the server has not been updated to support this. |
| 287 | """ |
| 288 | __slots__ = ('message', 'severity', 'cause', 'cause_stacktrace') |
| 289 | |
| 290 | def __init__(self, error: Dict[str, Any]): |
| 291 | self.message: Final[str] = error['message'] |
| 292 | severity = error['severity'] |
| 293 | self.severity: Final[Severity] = severity if isinstance(severity, Severity) else Severity.from_str(str(severity)) |
| 294 | self.cause: Final[str] = error['cause'] |
| 295 | self.cause_stacktrace: Final[str] = error.get('causeStackTrace', '') |
| 296 | |
| 297 | @classmethod |
| 298 | def create(cls, message: str, severity: Severity, cause: str, stacktrace: str = '') -> 'LoadResultError': |
| 299 | return cls({'message': message, 'severity': severity, 'cause': cause, 'causeStackTrace': stacktrace}) |
| 300 | |
| 301 | def __str__(self): |
| 302 | return f'{self.message}: {self.cause} ({self.severity})' |
| 303 | |
| 304 | def __repr__(self): |
| 305 | return f'<LoadResultError severity={self.severity} message={self.message} cause={self.cause}>' |
| 306 | |
| 307 | |
| 308 | class LoadResult: |