1package gocql 2 3import "fmt" 4 5const ( 6 errServer = 0x0000 7 errProtocol = 0x000A 8 errCredentials = 0x0100 9 errUnavailable = 0x1000 10 errOverloaded = 0x1001 11 errBootstrapping = 0x1002 12 errTruncate = 0x1003 13 errWriteTimeout = 0x1100 14 errReadTimeout = 0x1200 15 errReadFailure = 0x1300 16 errFunctionFailure = 0x1400 17 errWriteFailure = 0x1500 18 errCDCWriteFailure = 0x1600 19 errSyntax = 0x2000 20 errUnauthorized = 0x2100 21 errInvalid = 0x2200 22 errConfig = 0x2300 23 errAlreadyExists = 0x2400 24 errUnprepared = 0x2500 25) 26 27type RequestError interface { 28 Code() int 29 Message() string 30 Error() string 31} 32 33type errorFrame struct { 34 frameHeader 35 36 code int 37 message string 38} 39 40func (e errorFrame) Code() int { 41 return e.code 42} 43 44func (e errorFrame) Message() string { 45 return e.message 46} 47 48func (e errorFrame) Error() string { 49 return e.Message() 50} 51 52func (e errorFrame) String() string { 53 return fmt.Sprintf("[error code=%x message=%q]", e.code, e.message) 54} 55 56type RequestErrUnavailable struct { 57 errorFrame 58 Consistency Consistency 59 Required int 60 Alive int 61} 62 63func (e *RequestErrUnavailable) String() string { 64 return fmt.Sprintf("[request_error_unavailable consistency=%s required=%d alive=%d]", e.Consistency, e.Required, e.Alive) 65} 66 67type ErrorMap map[string]uint16 68 69type RequestErrWriteTimeout struct { 70 errorFrame 71 Consistency Consistency 72 Received int 73 BlockFor int 74 WriteType string 75} 76 77type RequestErrWriteFailure struct { 78 errorFrame 79 Consistency Consistency 80 Received int 81 BlockFor int 82 NumFailures int 83 WriteType string 84 ErrorMap ErrorMap 85} 86 87type RequestErrCDCWriteFailure struct { 88 errorFrame 89} 90 91type RequestErrReadTimeout struct { 92 errorFrame 93 Consistency Consistency 94 Received int 95 BlockFor int 96 DataPresent byte 97} 98 99type RequestErrAlreadyExists struct { 100 errorFrame 101 Keyspace string 102 Table string 103} 104 105type RequestErrUnprepared struct { 106 errorFrame 107 StatementId []byte 108} 109 110type RequestErrReadFailure struct { 111 errorFrame 112 Consistency Consistency 113 Received int 114 BlockFor int 115 NumFailures int 116 DataPresent bool 117 ErrorMap ErrorMap 118} 119 120type RequestErrFunctionFailure struct { 121 errorFrame 122 Keyspace string 123 Function string 124 ArgTypes []string 125} 126