errors.go 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package gocql
  2. const (
  3. errServer = 0x0000
  4. errProtocol = 0x000A
  5. errCredentials = 0x0100
  6. errUnavailable = 0x1000
  7. errOverloaded = 0x1001
  8. errBootstrapping = 0x1002
  9. errTruncate = 0x1003
  10. errWriteTimeout = 0x1100
  11. errReadTimeout = 0x1200
  12. errSyntax = 0x2000
  13. errUnauthorized = 0x2100
  14. errInvalid = 0x2200
  15. errConfig = 0x2300
  16. errAlreadyExists = 0x2400
  17. errUnprepared = 0x2500
  18. )
  19. type errorFrame interface {
  20. Code() int
  21. Message() string
  22. Error() string
  23. }
  24. type errorResponse struct {
  25. code int
  26. message string
  27. }
  28. func (e errorResponse) Code() int {
  29. return e.code
  30. }
  31. func (e errorResponse) Message() string {
  32. return e.message
  33. }
  34. func (e errorResponse) Error() string {
  35. return e.Message()
  36. }
  37. type errRespUnavailable struct {
  38. errorResponse
  39. Consistency Consistency
  40. Required int
  41. Alive int
  42. }
  43. type errRespWriteTimeout struct {
  44. errorResponse
  45. Consistency Consistency
  46. Received int
  47. BlockFor int
  48. WriteType string
  49. }
  50. type errRespReadTimeout struct {
  51. errorResponse
  52. Consistency Consistency
  53. Received int
  54. BlockFor int
  55. DataPresent byte
  56. }
  57. type errRespAlreadyExists struct {
  58. errorResponse
  59. Keyspace string
  60. Table string
  61. }
  62. type errRespUnprepared struct {
  63. errorResponse
  64. StatementId []byte
  65. }