CloudError.py 1.4 KB

12345678910111213141516171819202122232425262728293031
  1. # Copyright (c) 2021 Ultimaker B.V.
  2. # Cura is released under the terms of the LGPLv3 or higher.
  3. from typing import Dict, Optional, Any
  4. from .BaseModel import BaseModel
  5. class CloudError(BaseModel):
  6. """Class representing errors generated by the servers, according to the JSON-API standard."""
  7. def __init__(self, id: str, code: str, title: str, http_status: str, detail: Optional[str] = None,
  8. meta: Optional[Dict[str, Any]] = None, **kwargs) -> None:
  9. """Creates a new error object.
  10. :param id: Unique identifier for this particular occurrence of the problem.
  11. :param title: A short, human-readable summary of the problem that SHOULD NOT change from occurrence to occurrence
  12. of the problem, except for purposes of localization.
  13. :param code: An application-specific error code, expressed as a string value.
  14. :param detail: A human-readable explanation specific to this occurrence of the problem. Like title, this field's
  15. value can be localized.
  16. :param http_status: The HTTP status code applicable to this problem, converted to string.
  17. :param meta: Non-standard meta-information about the error, depending on the error code.
  18. """
  19. self.id = id
  20. self.code = code
  21. self.http_status = http_status
  22. self.title = title
  23. self.detail = detail
  24. self.meta = meta
  25. super().__init__(**kwargs)