code.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from __future__ import annotations
  2. __all__ = ["Code"]
  3. from enum import Enum
  4. class Code(Enum):
  5. """
  6. Enumeration of Connect error codes.
  7. """
  8. CANCELED = "canceled"
  9. """RPC canceled, usually by the caller."""
  10. UNKNOWN = "unknown"
  11. """Catch-all for errors of unclear origin and errors without a more appropriate code."""
  12. INVALID_ARGUMENT = "invalid_argument"
  13. """Request is invalid, regardless of system state."""
  14. DEADLINE_EXCEEDED = "deadline_exceeded"
  15. """Deadline expired before RPC could complete or before the client received the response."""
  16. NOT_FOUND = "not_found"
  17. """User requested a resource (for example, a file or directory) that can't be found."""
  18. ALREADY_EXISTS = "already_exists"
  19. """Caller attempted to create a resource that already exists."""
  20. PERMISSION_DENIED = "permission_denied"
  21. """Caller isn't authorized to perform the operation."""
  22. RESOURCE_EXHAUSTED = "resource_exhausted"
  23. """Operation can't be completed because some resource is exhausted. Use unavailable if the server
  24. is temporarily overloaded and the caller should retry later."""
  25. FAILED_PRECONDITION = "failed_precondition"
  26. """Operation can't be completed because the system isn't in the required state."""
  27. ABORTED = "aborted"
  28. """The operation was aborted, often because of concurrency issues like a database transaction abort."""
  29. OUT_OF_RANGE = "out_of_range"
  30. """The operation was attempted past the valid range."""
  31. UNIMPLEMENTED = "unimplemented"
  32. """The operation isn't implemented, supported, or enabled."""
  33. INTERNAL = "internal"
  34. """An invariant expected by the underlying system has been broken. Reserved for serious errors."""
  35. UNAVAILABLE = "unavailable"
  36. """The service is currently unavailable, usually transiently. Clients should back off and retry
  37. idempotent operations."""
  38. DATA_LOSS = "data_loss"
  39. """Unrecoverable data loss or corruption."""
  40. UNAUTHENTICATED = "unauthenticated"
  41. """Caller doesn't have valid authentication credentials for the operation."""