observed_error.py 971 B

1234567891011121314151617181920212223242526272829303132333435
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from dataclasses import dataclass, field
  10. @dataclass(unsafe_hash=True)
  11. class ObservedBaseError:
  12. internal_error_type: str
  13. occurrences: int = field(init=False, compare=False, hash=False)
  14. def to_text(self) -> str:
  15. raise NotImplementedError
  16. def to_markdown(self) -> str:
  17. raise NotImplementedError
  18. def occurrences_to_markdown(self) -> str:
  19. if self.occurrences < 2:
  20. return ""
  21. return f"\n({self.occurrences} occurrences)"
  22. @dataclass(unsafe_hash=True)
  23. class WithIssue:
  24. issue_number: int
  25. issue_url: str
  26. issue_title: str