errors.py 981 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from __future__ import annotations
  2. class Error(Exception):
  3. """Base W&B Error.
  4. <!-- lazydoc-ignore-class: internal -->
  5. """
  6. def __init__(self, message: str, context: dict | None = None) -> None:
  7. super().__init__(message)
  8. self.message = message
  9. # sentry context capture
  10. if context:
  11. self.context = context
  12. class CommError(Error):
  13. """Error communicating with W&B servers."""
  14. def __init__(self, msg: str, exc: Exception | None = None) -> None:
  15. self.exc = exc
  16. self.message = msg
  17. super().__init__(self.message)
  18. class AuthenticationError(CommError):
  19. """Raised when authentication fails."""
  20. class UsageError(Error):
  21. """Raised when an invalid usage of the SDK API is detected."""
  22. class UnsupportedError(UsageError):
  23. """Raised when trying to use a feature that is not supported."""
  24. class WandbCoreNotAvailableError(Error):
  25. """Raised when wandb core is not available."""