1#[derive(Debug, Clone)]
20pub struct ErrorCode {
21 code: i16,
22 message: &'static str,
23 retryable: bool,
24}
25
26impl ErrorCode {
27 const fn new(code: i16, message: &'static str, retryable: bool) -> ErrorCode {
28 ErrorCode {
29 code,
30 message,
31 retryable,
32 }
33 }
34
35 pub fn code(&self) -> i16 {
36 self.code
37 }
38
39 pub fn message(&self) -> &'static str {
40 self.message
41 }
42
43 pub fn retryable(&self) -> bool {
44 self.retryable
45 }
46}
47
48impl ErrorCode {
49 pub const UNKNOWN_SERVER_ERROR: Self = Self::new(
50 -1,
51 "The server experienced an unexpected error when processing the request.",
52 false,
53 );
54 pub const NONE: Self = Self::new(0, "", false);
55 pub const OFFSET_OUT_OF_RANGE: Self = Self::new(
56 1,
57 "The requested offset is not within the range of offsets maintained by the server.",
58 false,
59 );
60 pub const CORRUPT_MESSAGE: Self = Self::new(2, "This message has failed its CRC checksum, exceeds the valid size, has a null key for a compacted topic, or is otherwise corrupt.", true);
61 pub const UNKNOWN_TOPIC_OR_PARTITION: Self =
62 ErrorCode::new(3, "This server does not host this topic-partition.", true);
63 pub const INVALID_FETCH_SIZE: Self =
64 ErrorCode::new(4, "The requested fetch size is invalid.", false);
65 pub const LEADER_NOT_AVAILABLE: Self = Self::new(5, "There is no leader for this topic-partition as we are in the middle of a leadership election.", true);
66 pub const NOT_LEADER_OR_FOLLOWER: Self = Self::new(6, "For requests intended only for the leader, this error indicates that the broker is not the current leader. For requests intended for any replica, this error indicates that the broker is not a replica of the topic partition.", true);
67 pub const REQUEST_TIMED_OUT: Self = Self::new(7, "The request timed out.", true);
68 pub const BROKER_NOT_AVAILABLE: Self = Self::new(8, "The broker is not available.", false);
69 pub const REPLICA_NOT_AVAILABLE: Self = Self::new(9, "The replica is not available for the requested topic-partition. Produce/Fetch requests and other requests intended only for the leader or follower return NOT_LEADER_OR_FOLLOWER if the broker is not a replica of the topic-partition.", true);
70 pub const MESSAGE_TOO_LARGE: Self = Self::new(
71 10,
72 "The request included a message larger than the max message size the server will accept.",
73 false,
74 );
75 pub const STALE_CONTROLLER_EPOCH: Self =
76 ErrorCode::new(11, "The controller moved to another broker.", false);
77 pub const OFFSET_METADATA_TOO_LARGE: Self = Self::new(
78 12,
79 "The metadata field of the offset request was too large.",
80 false,
81 );
82 pub const NETWORK_EXCEPTION: Self = Self::new(
83 13,
84 "The server disconnected before a response was received.",
85 true,
86 );
87 pub const COORDINATOR_LOAD_IN_PROGRESS: Self = Self::new(
88 14,
89 "The coordinator is loading and hence can't process requests.",
90 true,
91 );
92 pub const COORDINATOR_NOT_AVAILABLE: Self =
93 ErrorCode::new(15, "The coordinator is not available.", true);
94 pub const NOT_COORDINATOR: Self = Self::new(16, "This is not the correct coordinator.", true);
95 pub const INVALID_TOPIC_EXCEPTION: Self = Self::new(
96 17,
97 "The request attempted to perform an operation on an invalid topic.",
98 false,
99 );
100 pub const RECORD_LIST_TOO_LARGE: Self = Self::new(
101 18,
102 "The request included message batch larger than the configured segment size on the server.",
103 false,
104 );
105 pub const NOT_ENOUGH_REPLICAS: Self = Self::new(
106 19,
107 "Messages are rejected since there are fewer in-sync replicas than required.",
108 true,
109 );
110 pub const NOT_ENOUGH_REPLICAS_AFTER_APPEND: Self = Self::new(
111 20,
112 "Messages are written to the log, but to fewer in-sync replicas than required.",
113 true,
114 );
115 pub const INVALID_REQUIRED_ACKS: Self = Self::new(
116 21,
117 "Produce request specified an invalid value for required acks.",
118 false,
119 );
120 pub const ILLEGAL_GENERATION: Self =
121 ErrorCode::new(22, "Specified group generation id is not valid.", false);
122 pub const INCONSISTENT_GROUP_PROTOCOL: Self = Self::new(23, "The group member's supported protocols are incompatible with those of existing members or first group member tried to join with empty protocol type or empty protocol list.", false);
123 pub const INVALID_GROUP_ID: Self = Self::new(24, "The configured groupId is invalid.", false);
124 pub const UNKNOWN_MEMBER_ID: Self =
125 ErrorCode::new(25, "The coordinator is not aware of this member.", false);
126 pub const INVALID_SESSION_TIMEOUT: Self = Self::new(26, "The session timeout is not within the range allowed by the broker (as configured by group.min.session.timeout.ms and group.max.session.timeout.ms).", false);
127 pub const REBALANCE_IN_PROGRESS: Self = Self::new(
128 27,
129 "The group is rebalancing, so a rejoin is needed.",
130 false,
131 );
132 pub const INVALID_COMMIT_OFFSET_SIZE: Self =
133 ErrorCode::new(28, "The committing offset data size is not valid.", false);
134 pub const TOPIC_AUTHORIZATION_FAILED: Self =
135 ErrorCode::new(29, "Topic authorization failed.", false);
136 pub const GROUP_AUTHORIZATION_FAILED: Self =
137 ErrorCode::new(30, "Group authorization failed.", false);
138 pub const CLUSTER_AUTHORIZATION_FAILED: Self =
139 ErrorCode::new(31, "Cluster authorization failed.", false);
140 pub const INVALID_TIMESTAMP: Self = Self::new(
141 32,
142 "The timestamp of the message is out of acceptable range.",
143 false,
144 );
145 pub const UNSUPPORTED_SASL_MECHANISM: Self = Self::new(
146 33,
147 "The broker does not support the requested SASL mechanism.",
148 false,
149 );
150 pub const ILLEGAL_SASL_STATE: Self = Self::new(
151 34,
152 "Request is not valid given the current SASL state.",
153 false,
154 );
155 pub const UNSUPPORTED_VERSION: Self =
156 ErrorCode::new(35, "The version of API is not supported.", false);
157 pub const TOPIC_ALREADY_EXISTS: Self =
158 ErrorCode::new(36, "Topic with this name already exists.", false);
159 pub const INVALID_PARTITIONS: Self = Self::new(37, "Number of partitions is below 1.", false);
160 pub const INVALID_REPLICATION_FACTOR: Self = Self::new(
161 38,
162 "Replication factor is below 1 or larger than the number of available brokers.",
163 false,
164 );
165 pub const INVALID_REPLICA_ASSIGNMENT: Self =
166 ErrorCode::new(39, "Replica assignment is invalid.", false);
167 pub const INVALID_CONFIG: Self = Self::new(40, "Configuration is invalid.", false);
168 pub const NOT_CONTROLLER: Self = Self::new(
169 41,
170 "This is not the correct controller for this cluster.",
171 true,
172 );
173 pub const INVALID_REQUEST: Self = Self::new(42, "This most likely occurs because of a request being malformed by the client library or the message was sent to an incompatible broker. See the broker logs for more details.", false);
174 pub const UNSUPPORTED_FOR_MESSAGE_FORMAT: Self = Self::new(
175 43,
176 "The message format version on the broker does not support the request.",
177 false,
178 );
179 pub const POLICY_VIOLATION: Self = Self::new(
180 44,
181 "Request parameters do not satisfy the configured policy.",
182 false,
183 );
184 pub const OUT_OF_ORDER_SEQUENCE_NUMBER: Self = Self::new(
185 45,
186 "The broker received an out of order sequence number.",
187 false,
188 );
189 pub const DUPLICATE_SEQUENCE_NUMBER: Self = Self::new(
190 46,
191 "The broker received a duplicate sequence number.",
192 false,
193 );
194 pub const INVALID_PRODUCER_EPOCH: Self = Self::new(
195 47,
196 "Producer attempted to produce with an old epoch.",
197 false,
198 );
199 pub const INVALID_TXN_STATE: Self = Self::new(
200 48,
201 "The producer attempted a transactional operation in an invalid state.",
202 false,
203 );
204 pub const INVALID_PRODUCER_ID_MAPPING: Self = Self::new(49, "The producer attempted to use a producer id which is not currently assigned to its transactional id.", false);
205 pub const INVALID_TRANSACTION_TIMEOUT: Self = Self::new(50, "The transaction timeout is larger than the maximum value allowed by the broker (as configured by transaction.max.timeout.ms).", false);
206 pub const CONCURRENT_TRANSACTIONS: Self = Self::new(51, "The producer attempted to update a transaction while another concurrent operation on the same transaction was ongoing.", true);
207 pub const TRANSACTION_COORDINATOR_FENCED: Self = Self::new(52, "Indicates that the transaction coordinator sending a WriteTxnMarker is no longer the current coordinator for a given producer.", false);
208 pub const TRANSACTIONAL_ID_AUTHORIZATION_FAILED: Self =
209 ErrorCode::new(53, "Transactional Id authorization failed.", false);
210 pub const SECURITY_DISABLED: Self = Self::new(54, "Security features are disabled.", false);
211 pub const OPERATION_NOT_ATTEMPTED: Self = Self::new(55, "The broker did not attempt to execute this operation. This may happen for batched RPCs where some operations in the batch failed, causing the broker to respond without trying the rest.", false);
212 pub const KAFKA_STORAGE_ERROR: Self = Self::new(
213 56,
214 "Disk error when trying to access log file on the disk.",
215 true,
216 );
217 pub const LOG_DIR_NOT_FOUND: Self = Self::new(
218 57,
219 "The user-specified log directory is not found in the broker config.",
220 false,
221 );
222 pub const SASL_AUTHENTICATION_FAILED: Self =
223 ErrorCode::new(58, "SASL Authentication failed.", false);
224 pub const UNKNOWN_PRODUCER_ID: Self = Self::new(59, "This exception is raised by the broker if it could not locate the producer metadata associated with the producerId in question. This could happen if, for instance, the producer's records were deleted because their retention time had elapsed. Once the last records of the producerId are removed, the producer's metadata is removed from the broker, and future appends by the producer will return this exception.", false);
225 pub const REASSIGNMENT_IN_PROGRESS: Self =
226 ErrorCode::new(60, "A partition reassignment is in progress.", false);
227 pub const DELEGATION_TOKEN_AUTH_DISABLED: Self =
228 ErrorCode::new(61, "Delegation Token feature is not enabled.", false);
229 pub const DELEGATION_TOKEN_NOT_FOUND: Self =
230 ErrorCode::new(62, "Delegation Token is not found on server.", false);
231 pub const DELEGATION_TOKEN_OWNER_MISMATCH: Self =
232 ErrorCode::new(63, "Specified Principal is not valid Owner/Renewer.", false);
233 pub const DELEGATION_TOKEN_REQUEST_NOT_ALLOWED: Self = Self::new(64, "Delegation Token requests are not allowed on PLAINTEXT/1-way SSL channels and on delegation token authenticated channels.", false);
234 pub const DELEGATION_TOKEN_AUTHORIZATION_FAILED: Self =
235 ErrorCode::new(65, "Delegation Token authorization failed.", false);
236 pub const DELEGATION_TOKEN_EXPIRED: Self =
237 ErrorCode::new(66, "Delegation Token is expired.", false);
238 pub const INVALID_PRINCIPAL_TYPE: Self =
239 ErrorCode::new(67, "Supplied principalType is not supported.", false);
240 pub const NON_EMPTY_GROUP: Self = Self::new(68, "The group is not empty.", false);
241 pub const GROUP_ID_NOT_FOUND: Self = Self::new(69, "The group id does not exist.", false);
242 pub const FETCH_SESSION_ID_NOT_FOUND: Self =
243 ErrorCode::new(70, "The fetch session ID was not found.", true);
244 pub const INVALID_FETCH_SESSION_EPOCH: Self =
245 ErrorCode::new(71, "The fetch session epoch is invalid.", true);
246 pub const LISTENER_NOT_FOUND: Self = Self::new(72, "There is no listener on the leader broker that matches the listener on which metadata request was processed.", true);
247 pub const TOPIC_DELETION_DISABLED: Self = Self::new(73, "Topic deletion is disabled.", false);
248 pub const FENCED_LEADER_EPOCH: Self = Self::new(
249 74,
250 "The leader epoch in the request is older than the epoch on the broker.",
251 true,
252 );
253 pub const UNKNOWN_LEADER_EPOCH: Self = Self::new(
254 75,
255 "The leader epoch in the request is newer than the epoch on the broker.",
256 true,
257 );
258 pub const UNSUPPORTED_COMPRESSION_TYPE: Self = Self::new(
259 76,
260 "The requesting client does not support the compression type of given partition.",
261 false,
262 );
263 pub const STALE_BROKER_EPOCH: Self = Self::new(77, "Broker epoch has changed.", false);
264 pub const OFFSET_NOT_AVAILABLE: Self = Self::new(78, "The leader high watermark has not caught up from a recent leader election so the offsets cannot be guaranteed to be monotonically increasing.", true);
265 pub const MEMBER_ID_REQUIRED: Self = Self::new(79, "The group member needs to have a valid member id before actually entering a consumer group.", false);
266 pub const PREFERRED_LEADER_NOT_AVAILABLE: Self =
267 ErrorCode::new(80, "The preferred leader was not available.", true);
268 pub const GROUP_MAX_SIZE_REACHED: Self =
269 ErrorCode::new(81, "The consumer group has reached its max size.", false);
270 pub const FENCED_INSTANCE_ID: Self = Self::new(82, "The broker rejected this static consumer since another consumer with the same group.instance.id has registered with a different member.id.", false);
271 pub const ELIGIBLE_LEADERS_NOT_AVAILABLE: Self = Self::new(
272 83,
273 "Eligible topic partition leaders are not available.",
274 true,
275 );
276 pub const ELECTION_NOT_NEEDED: Self =
277 ErrorCode::new(84, "Leader election not needed for topic partition.", true);
278 pub const NO_REASSIGNMENT_IN_PROGRESS: Self =
279 ErrorCode::new(85, "No partition reassignment is in progress.", false);
280 pub const GROUP_SUBSCRIBED_TO_TOPIC: Self = Self::new(86, "Deleting offsets of a topic is forbidden while the consumer group is actively subscribed to it.", false);
281 pub const INVALID_RECORD: Self = Self::new(
282 87,
283 "This record has failed the validation on broker and hence will be rejected.",
284 false,
285 );
286 pub const UNSTABLE_OFFSET_COMMIT: Self = Self::new(
287 88,
288 "There are unstable offsets that need to be cleared.",
289 true,
290 );
291 pub const THROTTLING_QUOTA_EXCEEDED: Self =
292 ErrorCode::new(89, "The throttling quota has been exceeded.", true);
293 pub const PRODUCER_FENCED: Self = Self::new(
294 90,
295 "There is a newer producer with the same transactionalId which fences the current one.",
296 false,
297 );
298 pub const RESOURCE_NOT_FOUND: Self = Self::new(
299 91,
300 "A request illegally referred to a resource that does not exist.",
301 false,
302 );
303 pub const DUPLICATE_RESOURCE: Self = Self::new(
304 92,
305 "A request illegally referred to the same resource twice.",
306 false,
307 );
308 pub const UNACCEPTABLE_CREDENTIAL: Self = Self::new(
309 93,
310 "Requested credential would not meet criteria for acceptability.",
311 false,
312 );
313 pub const INCONSISTENT_VOTER_SET: Self = Self::new(94, "Indicates that the either the sender or recipient of a voter-only request is not one of the expected voters", false);
314 pub const INVALID_UPDATE_VERSION: Self =
315 ErrorCode::new(95, "The given update version was invalid.", false);
316 pub const FEATURE_UPDATE_FAILED: Self = Self::new(
317 96,
318 "Unable to update finalized features due to an unexpected server error.",
319 false,
320 );
321 pub const PRINCIPAL_DESERIALIZATION_FAILURE: Self = Self::new(97, "Request principal deserialization failed during forwarding. This indicates an internal error on the broker cluster security setup.", false);
322 pub const SNAPSHOT_NOT_FOUND: Self = Self::new(98, "Requested snapshot was not found", false);
323 pub const POSITION_OUT_OF_RANGE: Self = Self::new(99, "Requested position is not greater than or equal to zero, and less than the size of the snapshot.", false);
324 pub const UNKNOWN_TOPIC_ID: Self =
325 ErrorCode::new(100, "This server does not host this topic ID.", true);
326 pub const DUPLICATE_BROKER_REGISTRATION: Self =
327 ErrorCode::new(101, "This broker ID is already in use.", false);
328 pub const BROKER_ID_NOT_REGISTERED: Self =
329 ErrorCode::new(102, "The given broker ID was not registered.", false);
330 pub const INCONSISTENT_TOPIC_ID: Self = Self::new(
331 103,
332 "The log's topic ID did not match the topic ID in the request",
333 true,
334 );
335 pub const INCONSISTENT_CLUSTER_ID: Self = Self::new(
336 104,
337 "The clusterId in the request does not match that found on the server",
338 false,
339 );
340 pub const TRANSACTIONAL_ID_NOT_FOUND: Self =
341 ErrorCode::new(105, "The transactionalId could not be found", false);
342 pub const FETCH_SESSION_TOPIC_ID_ERROR: Self = Self::new(
343 106,
344 "The fetch session encountered inconsistent topic ID usage",
345 true,
346 );
347 pub const INELIGIBLE_REPLICA: Self = Self::new(
348 107,
349 "The new ISR contains at least one ineligible replica.",
350 false,
351 );
352 pub const NEW_LEADER_ELECTED: Self = Self::new(108, "The AlterPartition request successfully updated the partition state but the leader has changed.", false);
353 pub const OFFSET_MOVED_TO_TIERED_STORAGE: Self = Self::new(
354 109,
355 "The requested offset is moved to tiered storage.",
356 false,
357 );
358 pub const FENCED_MEMBER_EPOCH: Self = Self::new(110, "The member epoch is fenced by the group coordinator. The member must abandon all its partitions and rejoin.", false);
359 pub const UNRELEASED_INSTANCE_ID: Self = Self::new(111, "The instance ID is still used by another member in the consumer group. That member must leave first.", false);
360 pub const UNSUPPORTED_ASSIGNOR: Self = Self::new(
361 112,
362 "The assignor or its version range is not supported by the consumer group.",
363 false,
364 );
365 pub const STALE_MEMBER_EPOCH: Self = Self::new(113, "The member epoch is stale. The member must retry after receiving its updated member epoch via the ConsumerGroupHeartbeat API.", false);
366 pub const MISMATCHED_ENDPOINT_TYPE: Self = Self::new(
367 114,
368 "The request was sent to an endpoint of the wrong type.",
369 false,
370 );
371 pub const UNSUPPORTED_ENDPOINT_TYPE: Self =
372 ErrorCode::new(115, "This endpoint type is not supported yet.", false);
373 pub const UNKNOWN_CONTROLLER_ID: Self =
374 ErrorCode::new(116, "This controller ID is not known.", false);
375 pub const UNKNOWN_SUBSCRIPTION_ID: Self = Self::new(
376 117,
377 "Client sent a push telemetry request with an invalid or outdated subscription ID.",
378 false,
379 );
380 pub const TELEMETRY_TOO_LARGE: Self = Self::new(
381 118,
382 "Client sent a push telemetry request larger than the maximum size the broker will accept.",
383 false,
384 );
385 pub const INVALID_REGISTRATION: Self = Self::new(
386 119,
387 "The controller has considered the broker registration to be invalid.",
388 false,
389 );
390}