@@ -111,6 +111,7 @@ const (
111111 ErrCodeUnprepared = 0x2500
112112)
113113
114+ // RequestError represents errors returned by Cassandra server.
114115type RequestError interface {
115116 Code () int
116117 Message () string
@@ -140,6 +141,8 @@ func (e errorFrame) String() string {
140141 return fmt .Sprintf ("[error code=%x message=%q]" , e .code , e .message )
141142}
142143
144+ // RequestErrUnavailable represents an unavailable error returned by Cassandra.
145+ // This error occurs when there are not enough nodes available to fulfill the request.
143146type RequestErrUnavailable struct {
144147 errorFrame
145148 Consistency Consistency
@@ -151,8 +154,14 @@ func (e *RequestErrUnavailable) String() string {
151154 return fmt .Sprintf ("[request_error_unavailable consistency=%s required=%d alive=%d]" , e .Consistency , e .Required , e .Alive )
152155}
153156
157+ // ErrorMap maps node IP addresses to their respective error codes for read/write failure responses.
158+ // Each entry represents a node that failed during the operation, with the key being the node's
159+ // IP address as a string and the value being the specific error code returned by that node.
154160type ErrorMap map [string ]uint16
155161
162+ // RequestErrWriteTimeout represents a write timeout error returned by Cassandra.
163+ // This error occurs when a write request times out after the coordinator
164+ // has successfully written to some replicas but not enough to satisfy the required consistency level.
156165type RequestErrWriteTimeout struct {
157166 errorFrame
158167 Consistency Consistency
@@ -161,6 +170,8 @@ type RequestErrWriteTimeout struct {
161170 WriteType string
162171}
163172
173+ // RequestErrWriteFailure represents a write failure error returned by Cassandra.
174+ // This error occurs when a write request fails on one or more replicas.
164175type RequestErrWriteFailure struct {
165176 errorFrame
166177 Consistency Consistency
@@ -171,10 +182,15 @@ type RequestErrWriteFailure struct {
171182 ErrorMap ErrorMap
172183}
173184
185+ // RequestErrCDCWriteFailure represents a CDC write failure error returned by Cassandra.
186+ // This error occurs when a write to the Change Data Capture log fails.
174187type RequestErrCDCWriteFailure struct {
175188 errorFrame
176189}
177190
191+ // RequestErrReadTimeout represents a read timeout error returned by Cassandra.
192+ // This error occurs when a read request times out after the coordinator
193+ // has received some responses but not enough to satisfy the required consistency level.
178194type RequestErrReadTimeout struct {
179195 errorFrame
180196 Consistency Consistency
@@ -183,17 +199,23 @@ type RequestErrReadTimeout struct {
183199 DataPresent byte
184200}
185201
202+ // RequestErrAlreadyExists represents an "already exists" error returned by Cassandra.
203+ // This error occurs when attempting to create a keyspace or table that already exists.
186204type RequestErrAlreadyExists struct {
187205 errorFrame
188206 Keyspace string
189207 Table string
190208}
191209
210+ // RequestErrUnprepared represents an "unprepared" error returned by Cassandra.
211+ // This error occurs when a prepared statement is no longer available on the server.
192212type RequestErrUnprepared struct {
193213 errorFrame
194214 StatementId []byte
195215}
196216
217+ // RequestErrReadFailure represents a read failure error returned by Cassandra.
218+ // This error occurs when a read request fails on one or more replicas.
197219type RequestErrReadFailure struct {
198220 errorFrame
199221 Consistency Consistency
@@ -204,6 +226,8 @@ type RequestErrReadFailure struct {
204226 ErrorMap ErrorMap
205227}
206228
229+ // RequestErrFunctionFailure represents a function failure error returned by Cassandra.
230+ // This error occurs when a user-defined function fails during execution.
207231type RequestErrFunctionFailure struct {
208232 errorFrame
209233 Keyspace string
0 commit comments