Skip to main content

confluent_kafka/common/
error.rs

1// Copyright 2025 Confluent Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! The crate's flat base error type and the machinery behind it.
16//!
17//! [`Error`] is the single type every fallible API returns. It has no Java
18//! counterpart: Rust cannot express Java's exception hierarchy, so one enum
19//! holds both `KafkaException`'s subclasses and the generic `java.lang` /
20//! `java.util` runtime exceptions that sit beside it (CLAUDE.md §12.3).
21//!
22//! Flattening the hierarchy destroys the `extends` chain, so the traits and
23//! macros that reconstruct it live here too, next to the enum they serve:
24//!
25//!  - [`ErrorHierarchy`] recovers each intermediate Java class as a predicate;
26//!    [`ErrorCode`], [`ErrorName`], [`ErrorMessage`] and [`ErrorSource`] are the
27//!    per-payload answers [`Error`] delegates to.
28//!  - [`kafka_error_type`] and [`message_only_error`] declare the two shapes of
29//!    error class that carry nothing beyond a message, one per Java class.
30//!
31//! Java's `KafkaException` base class is a *different* type: the `KafkaError`
32//! struct, which every specific error struct embeds and which is re-exported
33//! alongside this enum as [`crate::common::KafkaError`].
34//! [`Error::KafkaError`](Error::KafkaError) is therefore the variant for a
35//! *bare* `KafkaException` — one with no subclass-specific fields. It is NOT
36//! "the variant for Kafka errors"; [`Error::Timeout`](Error::Timeout) and the
37//! rest are Kafka errors too. See [`Error::is_kafka_error`] for that test.
38
39// `#[delegatable_trait_remote]` (below) expands to a helper trait,
40// `MatchDisplay`, that the `Delegate` derive on `Error` makes reachable without
41// being nameable. It is macro plumbing, not API, and ambassador neither forwards
42// attributes to it nor lets it move into a submodule, so the allowance is
43// file-wide. It covers only items defined in this file: a crate-private type
44// leaking from elsewhere is still reported at its own definition.
45#![expect(unnameable_types)]
46
47use std::collections::HashSet;
48use std::ffi::c_void;
49// Imported unqualified so that `#[delegate(Display)]` on `Error` resolves to
50// the std trait; the `#[delegatable_trait_remote]` stub below only registers
51// the signature with ambassador, it does not define a trait.
52use std::fmt::Display;
53
54use ambassador::{Delegate, delegatable_trait, delegatable_trait_remote};
55
56use super::protocol::Errors;
57use crate::common::InvalidRecordError;
58use crate::common::KafkaError;
59use crate::common::LocalCallbackError;
60use crate::common::LocalConcurrentModificationError;
61use crate::common::LocalIllegalArgumentError;
62use crate::common::LocalIllegalStateError;
63use crate::common::LocalTimeoutError;
64use crate::common::LocalUnsupportedOperationError;
65use crate::common::config::ConfigError;
66use crate::common::errors::{
67    ApiError, AuthenticationError, AuthorizationError, AuthorizerNotReadyError, BootstrapResolutionError,
68    BrokerIdNotRegisteredError, BrokerNotAvailableError, ClusterAuthorizationError, ConcurrentTransactionsError,
69    ControllerIdNotRegisteredError, ControllerMovedError, CoordinatorLoadInProgressError, CoordinatorNotAvailableError,
70    CorruptRecordError, DelegationTokenAuthorizationError, DelegationTokenDisabledError, DelegationTokenExpiredError,
71    DelegationTokenNotFoundError, DelegationTokenOwnerMismatchError, DisconnectError, DuplicateBrokerRegistrationError,
72    DuplicateResourceError, DuplicateSequenceError, DuplicateVoterError, ElectionNotNeededError,
73    EligibleLeadersNotAvailableError, FeatureUpdateFailedError, FencedInstanceIdError, FencedLeaderEpochError,
74    FencedMemberEpochError, FencedStateEpochError, FetchSessionIdNotFoundError, FetchSessionTopicIdError,
75    GroupAuthorizationError, GroupDeletionFailedError, GroupIdNotFoundError, GroupMaxSizeReachedError,
76    GroupNotEmptyError, GroupSubscribedToTopicError, IllegalGenerationError, IllegalSaslStateError,
77    InconsistentClusterIdError, InconsistentGroupProtocolError, InconsistentTopicIdError, InconsistentVoterSetError,
78    IneligibleReplicaError, InterruptError, InvalidCommitOffsetSizeError, InvalidConfigurationError,
79    InvalidFetchSessionEpochError, InvalidFetchSizeError, InvalidGroupIdError, InvalidOffsetError,
80    InvalidPartitionsError, InvalidPidMappingError, InvalidPrincipalTypeError, InvalidProducerEpochError,
81    InvalidRecordStateError, InvalidRegistrationError, InvalidRegularExpression, InvalidReplicaAssignmentError,
82    InvalidReplicationFactorError, InvalidRequestError, InvalidRequiredAcksError, InvalidSessionTimeoutError,
83    InvalidShareSessionEpochError, InvalidTimestampError, InvalidTopicError, InvalidTxnStateError,
84    InvalidTxnTimeoutError, InvalidUpdateVersionError, InvalidVoterKeyError, KafkaStorageError,
85    LeaderNotAvailableError, ListenerNotFoundError, LogDirNotFoundError, MemberIdRequiredError,
86    MismatchedEndpointTypeError, NetworkError, NewLeaderElectedError, NoReassignmentInProgressError,
87    NotControllerError, NotCoordinatorError, NotEnoughReplicasAfterAppendError, NotEnoughReplicasError,
88    NotLeaderOrFollowerError, OffsetMetadataTooLarge, OffsetMovedToTieredStorageError, OffsetNotAvailableError,
89    OffsetOutOfRangeError, OperationNotAttemptedError, OutOfOrderSequenceError, PolicyViolationError,
90    PositionOutOfRangeError, PreferredLeaderNotAvailableError, PrincipalDeserializationError, ProducerFencedError,
91    ReassignmentInProgressError, RebalanceInProgressError, RebootstrapRequiredError, RecordBatchTooLargeError,
92    RecordDeserializationError, RecordTooLargeError, ReplicaNotAvailableError, ResourceNotFoundError,
93    SaslAuthenticationError, SecurityDisabledError, SerializationError, ShareSessionLimitReachedError,
94    ShareSessionNotFoundError, SnapshotNotFoundError, SslAuthenticationError, StaleBrokerEpochError,
95    StaleMemberEpochError, StreamsInvalidTopologyEpochError, StreamsInvalidTopologyError,
96    StreamsTopologyDescriptionUpdateFailedError, StreamsTopologyFencedError, TelemetryTooLargeError,
97    ThrottlingQuotaExceededError, TimeoutError, TopicAuthorizationError, TopicDeletionDisabledError, TopicExistsError,
98    TransactionAbortableError, TransactionAbortedError, TransactionCoordinatorFencedError,
99    TransactionalIdAuthorizationError, TransactionalIdNotFoundError, UnacceptableCredentialError,
100    UnknownControllerIdError, UnknownLeaderEpochError, UnknownMemberIdError, UnknownProducerIdError,
101    UnknownServerError, UnknownSubscriptionIdError, UnknownTopicIdError, UnknownTopicOrPartitionError,
102    UnreleasedInstanceIdError, UnstableOffsetCommitError, UnsupportedAssignorError, UnsupportedByAuthenticationError,
103    UnsupportedCompressionTypeError, UnsupportedEndpointTypeError, UnsupportedForMessageFormatError,
104    UnsupportedSaslMechanismError, UnsupportedVersionError, VoterNotFoundError, WakeupError,
105};
106use crate::common::metrics::QuotaViolationError;
107use crate::common::network::InvalidReceiveError;
108use crate::common::protocol::types::SchemaError;
109use crate::common::requests::CorrelationIdMismatchError;
110use crate::consumer::{
111    ConsumerCommitFailedError, ConsumerLogTruncationError, ConsumerNoOffsetForPartitionError,
112    ConsumerOffsetOutOfRangeError, ConsumerRetriableCommitFailedError,
113};
114use crate::producer::ProducerBufferExhaustedError;
115
116/// Registers `std::fmt::Display` for delegation.
117///
118/// Ambassador cannot see a foreign trait's signature, so it is restated here.
119/// This declaration defines nothing — the attribute consumes it and emits only
120/// the delegation macro, which is why `Display` above still refers to the std
121/// trait.
122#[delegatable_trait_remote]
123trait Display {
124    fn fmt(&self, f: &mut ::std::fmt::Formatter) -> Result<(), ::std::fmt::Error>;
125}
126
127// ---------------------------------------------------------------------------
128// The exception hierarchy, as a trait
129// ---------------------------------------------------------------------------
130
131/// Java's exception hierarchy, recovered as a set of predicates.
132///
133/// **Mechanism, not API.** This trait is `pub(crate)`: it exists so each error
134/// payload can declare its ancestry once, and so ambassador can generate
135/// [`Error`]'s forwarding. Callers use the inherent methods on [`Error`], which
136/// carry the public documentation for each predicate.
137///
138/// It has no Java counterpart — it is the Rust encoding of the `extends` chain
139/// that [`Error`] flattens away (CLAUDE.md §12.3/§12.4). One method per
140/// **intermediate** class in Java's tree, then one *class predicate* per
141/// [`Error`] variant whose class is not already among them (CLAUDE.md §3).
142/// Leaf classes get one too: a Java release may add a subclass to any class,
143/// which becomes a new variant here, and a caller testing the predicate keeps
144/// matching it where a variant match would not.
145///
146/// Every method defaults to `false`, so each concrete error type declares its
147/// ancestry by overriding exactly the predicates that are `true` for it. The
148/// override list of an `impl` therefore reads as that type's Java `extends`
149/// chain, which is the property a flat enum otherwise destroys:
150///
151/// ```text
152/// TimeoutException extends RetriableException extends ApiException extends KafkaException
153///   => is_retriable_error + is_api_error + is_kafka_error are overridden to true
154/// ```
155///
156/// [`Error`] implements this trait through ambassador's `#[derive(Delegate)]`,
157/// which generates the `match` forwarding each predicate to the variant's
158/// payload. That is why every variant carries a distinct payload type: the
159/// payload — not the variant — is what answers the question, and two variants
160/// sharing one type could only ever give one answer.
161///
162/// Predicates are NOT complements of one another. [`SerializationError`] and
163/// [`WakeupError`] are `KafkaException`s that are not `ApiException`s, so they
164/// answer `true` to [`is_kafka_error`](Self::is_kafka_error) and `false` to
165/// [`is_api_error`](Self::is_api_error).
166#[delegatable_trait]
167pub(crate) trait ErrorHierarchy {
168    /// Whether this is a Kafka error rather than a generic programming error —
169    /// Java's `t instanceof KafkaException`.
170    ///
171    /// `false` for exactly the generic `java.lang` / `java.util` runtime
172    /// exceptions, which are siblings of `KafkaException` rather than
173    /// subclasses (`org.apache.kafka.common.KafkaException` extends `RuntimeException`): [`LocalIllegalArgumentError`],
174    /// [`LocalIllegalStateError`], [`LocalConcurrentModificationError`],
175    /// [`LocalTimeoutError`], [`LocalUnsupportedOperationError`] — and
176    /// [`LocalCallbackError`], which has no Java class
177    /// but stands in for a foreign callback's `Throwable`.
178    ///
179    /// Two call sites depend on this: `ConsumerUtils.maybeWrapAsKafkaException`
180    /// (a Kafka error passes through unchanged, a generic one gets wrapped),
181    /// and `FetchCollector`, whose Java `catch (KafkaException e)` cannot catch
182    /// a generic error.
183    fn is_kafka_error(&self) -> bool {
184        false
185    }
186
187    /// Whether this error's Java class extends `ApiException`.
188    ///
189    /// Narrower than [`is_kafka_error`](Self::is_kafka_error):
190    /// `SerializationException` and `WakeupException` extend `KafkaException`
191    /// directly, bypassing `ApiException`. `KafkaProducer.doSend()` catches
192    /// `ApiException` and fails the record's future; anything else propagates.
193    fn is_api_error(&self) -> bool {
194        false
195    }
196
197    /// Whether this error's Java class extends `RetriableException` — i.e.
198    /// whether re-sending the failed request can succeed.
199    fn is_retriable_error(&self) -> bool {
200        false
201    }
202
203    /// Whether this error's Java class extends `RefreshRetriableException` —
204    /// retriable, and a metadata / coordinator refresh is what clears it.
205    fn is_refresh_retriable_error(&self) -> bool {
206        false
207    }
208
209    /// Whether this error's Java class extends `TimeoutException`.
210    ///
211    /// Intermediate because `BufferExhaustedException extends TimeoutException`
212    /// (`clients/producer/BufferExhaustedException.java`), so Java's
213    /// `catch (TimeoutException e)` catches the buffer-exhausted case too.
214    fn is_timeout_error(&self) -> bool {
215        false
216    }
217
218    /// Whether this error's Java class extends `InvalidMetadataException` — the
219    /// client's cached metadata may be stale.
220    fn is_invalid_metadata_error(&self) -> bool {
221        false
222    }
223
224    /// Whether this error's Java class extends `InvalidConfigurationException`.
225    ///
226    /// Parent of BOTH [`is_authentication_error`](Self::is_authentication_error)
227    /// and [`is_authorization_error`](Self::is_authorization_error) — in Kafka
228    /// 4.2 those two extend `InvalidConfigurationException`, not `ApiException`
229    /// directly, so anything answering `true` to either must answer `true` here.
230    fn is_invalid_configuration_error(&self) -> bool {
231        false
232    }
233
234    /// Whether this error's Java class extends `ApplicationRecoverableException`
235    /// — the application can recover by re-initialising its producer or
236    /// rejoining its group, but the current epoch / session is lost.
237    fn is_application_recoverable_error(&self) -> bool {
238        false
239    }
240
241    /// Whether this error's Java class extends `InvalidOffsetException`.
242    fn is_invalid_offset_error(&self) -> bool {
243        false
244    }
245
246    /// Whether this error's Java class extends
247    /// `org.apache.kafka.clients.consumer.InvalidOffsetException`.
248    ///
249    /// A **different** class from the one
250    /// [`is_invalid_offset_error`](Self::is_invalid_offset_error) tests: the
251    /// consumer package has its own abstract `InvalidOffsetException` extending
252    /// `KafkaException`, whereas `common.errors`' is concrete and extends
253    /// `ApiException`. Java keeps them apart by package; this flat namespace
254    /// cannot, so the package is carried in the name.
255    fn is_consumer_invalid_offset_error(&self) -> bool {
256        false
257    }
258
259    /// Whether this error's Java class extends
260    /// `org.apache.kafka.clients.consumer.OffsetOutOfRangeException`.
261    ///
262    /// Intermediate because `LogTruncationException` extends it
263    /// (`clients/consumer/LogTruncationException.java`). Nested inside
264    /// [`is_consumer_invalid_offset_error`](Self::is_consumer_invalid_offset_error),
265    /// and distinct from the `common.errors` class of the same name.
266    fn is_consumer_offset_out_of_range_error(&self) -> bool {
267        false
268    }
269
270    /// Whether this error's Java class extends `OutOfOrderSequenceException`.
271    fn is_out_of_order_sequence_error(&self) -> bool {
272        false
273    }
274
275    /// Whether this error's Java class extends `SerializationException`.
276    ///
277    /// No protocol code maps here — `SerializationException` and its subclass
278    /// `RecordDeserializationException` are raised client-side — so only the
279    /// [`SerializationError`] payload answers `true`.
280    fn is_serialization_error(&self) -> bool {
281        false
282    }
283
284    /// Whether this error's Java class extends `AuthenticationException`.
285    ///
286    /// Overridden by the five payloads whose `extends:` list names it:
287    /// [`AuthenticationError`] itself — the concrete base class, which has no
288    /// `Errors` entry of its own but reports [`Errors::InvalidConfig`] through
289    /// `forException`'s superclass walk — plus [`SaslAuthenticationError`],
290    /// [`SslAuthenticationError`], [`IllegalSaslStateError`] and
291    /// [`UnsupportedSaslMechanismError`]. Only three of the five have an entry
292    /// in `Errors`, so this is NOT "the broker-reported codes": a handshake
293    /// failure detected locally is carried, as the class it was raised as,
294    /// inside an `io::Error` (`common::network::authentication_io_error`) and
295    /// reaches the application unchanged, answering `true` here.
296    fn is_authentication_error(&self) -> bool {
297        false
298    }
299
300    /// Whether this error's Java class extends `AuthorizationException`.
301    ///
302    /// Overridden by the six payloads whose `extends:` list names it:
303    /// [`AuthorizationError`] itself — the concrete base class, which reports
304    /// [`Errors::InvalidConfig`] by inheritance and carries no
305    /// protocol code — plus [`TopicAuthorizationError`],
306    /// [`GroupAuthorizationError`], [`ClusterAuthorizationError`],
307    /// [`TransactionalIdAuthorizationError`] and
308    /// [`DelegationTokenAuthorizationError`].
309    fn is_authorization_error(&self) -> bool {
310        false
311    }
312
313    // -- Class predicates ------------------------------------------------
314    //
315    // One per `Error` variant whose class is not already an intermediate
316    // predicate above (CLAUDE.md §3: every error has its predicate). Each
317    // means "this class or any subclass": a Java subclass added later becomes
318    // a new variant whose payload lists its parent's predicate here too, so a
319    // caller testing the predicate keeps matching it where a variant match
320    // would not. `cargo xtask lint-custom` (`check-error-predicate`) keeps this
321    // list, the `Box` forwarders, the `Error` forwarders and the C exports in
322    // step with the enum.
323
324    /// Whether this error's Java class is, or extends, `java.lang.IllegalArgumentException`.
325    fn is_local_illegal_argument_error(&self) -> bool {
326        false
327    }
328
329    /// Whether this error's Java class is, or extends, `java.lang.IllegalStateException`.
330    fn is_local_illegal_state_error(&self) -> bool {
331        false
332    }
333
334    /// Whether this error's Java class is, or extends, `java.util.ConcurrentModificationException`.
335    fn is_local_concurrent_modification_error(&self) -> bool {
336        false
337    }
338
339    /// Whether this error's Java class is, or extends, `java.util.concurrent.TimeoutException`.
340    fn is_local_timeout_error(&self) -> bool {
341        false
342    }
343
344    /// Whether this error's Java class is, or extends, `java.lang.UnsupportedOperationException`.
345    fn is_local_unsupported_operation_error(&self) -> bool {
346        false
347    }
348
349    /// Whether this is an error raised by a callback written in another
350    /// language ([`LocalCallbackError`]; no Java class).
351    fn is_local_callback_error(&self) -> bool {
352        false
353    }
354
355    /// Whether this error's Java class is, or extends,
356    /// `org.apache.kafka.common.errors.AuthorizerNotReadyException`.
357    fn is_authorizer_not_ready_error(&self) -> bool {
358        false
359    }
360
361    /// Whether this error's Java class is, or extends,
362    /// `org.apache.kafka.common.errors.BootstrapResolutionException`.
363    fn is_bootstrap_resolution_error(&self) -> bool {
364        false
365    }
366
367    /// Whether this error's Java class is, or extends,
368    /// `org.apache.kafka.common.errors.BrokerIdNotRegisteredException`.
369    fn is_broker_id_not_registered_error(&self) -> bool {
370        false
371    }
372
373    /// Whether this error's Java class is, or extends,
374    /// `org.apache.kafka.common.errors.BrokerNotAvailableException`.
375    fn is_broker_not_available_error(&self) -> bool {
376        false
377    }
378
379    /// Whether this error's Java class is, or extends,
380    /// `org.apache.kafka.clients.producer.BufferExhaustedException`.
381    fn is_producer_buffer_exhausted_error(&self) -> bool {
382        false
383    }
384
385    /// Whether this error's Java class is, or extends,
386    /// `org.apache.kafka.common.errors.ClusterAuthorizationException`.
387    fn is_cluster_authorization_error(&self) -> bool {
388        false
389    }
390
391    /// Whether this error's Java class is, or extends,
392    /// `org.apache.kafka.common.errors.ConcurrentTransactionsException`.
393    fn is_concurrent_transactions_error(&self) -> bool {
394        false
395    }
396
397    /// Whether this error's Java class is, or extends,
398    /// `org.apache.kafka.common.errors.ControllerIdNotRegisteredException`.
399    fn is_controller_id_not_registered_error(&self) -> bool {
400        false
401    }
402
403    /// Whether this error's Java class is, or extends,
404    /// `org.apache.kafka.common.errors.ControllerMovedException`.
405    fn is_controller_moved_error(&self) -> bool {
406        false
407    }
408
409    /// Whether this error's Java class is, or extends,
410    /// `org.apache.kafka.common.errors.CoordinatorLoadInProgressException`.
411    fn is_coordinator_load_in_progress_error(&self) -> bool {
412        false
413    }
414
415    /// Whether this error's Java class is, or extends,
416    /// `org.apache.kafka.common.errors.CoordinatorNotAvailableException`.
417    fn is_coordinator_not_available_error(&self) -> bool {
418        false
419    }
420
421    /// Whether this error's Java class is, or extends,
422    /// `org.apache.kafka.common.requests.CorrelationIdMismatchException`.
423    fn is_correlation_id_mismatch_error(&self) -> bool {
424        false
425    }
426
427    /// Whether this error's Java class is, or extends,
428    /// `org.apache.kafka.common.errors.CorruptRecordException`.
429    fn is_corrupt_record_error(&self) -> bool {
430        false
431    }
432
433    /// Whether this error's Java class is, or extends,
434    /// `org.apache.kafka.common.errors.DelegationTokenAuthorizationException`.
435    fn is_delegation_token_authorization_error(&self) -> bool {
436        false
437    }
438
439    /// Whether this error's Java class is, or extends,
440    /// `org.apache.kafka.common.errors.DelegationTokenDisabledException`.
441    fn is_delegation_token_disabled_error(&self) -> bool {
442        false
443    }
444
445    /// Whether this error's Java class is, or extends,
446    /// `org.apache.kafka.common.errors.DelegationTokenExpiredException`.
447    fn is_delegation_token_expired_error(&self) -> bool {
448        false
449    }
450
451    /// Whether this error's Java class is, or extends,
452    /// `org.apache.kafka.common.errors.DelegationTokenNotFoundException`.
453    fn is_delegation_token_not_found_error(&self) -> bool {
454        false
455    }
456
457    /// Whether this error's Java class is, or extends,
458    /// `org.apache.kafka.common.errors.DelegationTokenOwnerMismatchException`.
459    fn is_delegation_token_owner_mismatch_error(&self) -> bool {
460        false
461    }
462
463    /// Whether this error's Java class is, or extends,
464    /// `org.apache.kafka.common.errors.DisconnectException`.
465    fn is_disconnect_error(&self) -> bool {
466        false
467    }
468
469    /// Whether this error's Java class is, or extends,
470    /// `org.apache.kafka.common.errors.DuplicateBrokerRegistrationException`.
471    fn is_duplicate_broker_registration_error(&self) -> bool {
472        false
473    }
474
475    /// Whether this error's Java class is, or extends,
476    /// `org.apache.kafka.common.errors.DuplicateResourceException`.
477    fn is_duplicate_resource_error(&self) -> bool {
478        false
479    }
480
481    /// Whether this error's Java class is, or extends,
482    /// `org.apache.kafka.common.errors.DuplicateSequenceException`.
483    fn is_duplicate_sequence_error(&self) -> bool {
484        false
485    }
486
487    /// Whether this error's Java class is, or extends,
488    /// `org.apache.kafka.common.errors.DuplicateVoterException`.
489    fn is_duplicate_voter_error(&self) -> bool {
490        false
491    }
492
493    /// Whether this error's Java class is, or extends,
494    /// `org.apache.kafka.common.errors.ElectionNotNeededException`.
495    fn is_election_not_needed_error(&self) -> bool {
496        false
497    }
498
499    /// Whether this error's Java class is, or extends,
500    /// `org.apache.kafka.common.errors.EligibleLeadersNotAvailableException`.
501    fn is_eligible_leaders_not_available_error(&self) -> bool {
502        false
503    }
504
505    /// Whether this error's Java class is, or extends,
506    /// `org.apache.kafka.common.errors.FeatureUpdateFailedException`.
507    fn is_feature_update_failed_error(&self) -> bool {
508        false
509    }
510
511    /// Whether this error's Java class is, or extends,
512    /// `org.apache.kafka.common.errors.FencedInstanceIdException`.
513    fn is_fenced_instance_id_error(&self) -> bool {
514        false
515    }
516
517    /// Whether this error's Java class is, or extends,
518    /// `org.apache.kafka.common.errors.FencedLeaderEpochException`.
519    fn is_fenced_leader_epoch_error(&self) -> bool {
520        false
521    }
522
523    /// Whether this error's Java class is, or extends,
524    /// `org.apache.kafka.common.errors.FencedMemberEpochException`.
525    fn is_fenced_member_epoch_error(&self) -> bool {
526        false
527    }
528
529    /// Whether this error's Java class is, or extends,
530    /// `org.apache.kafka.common.errors.FencedStateEpochException`.
531    fn is_fenced_state_epoch_error(&self) -> bool {
532        false
533    }
534
535    /// Whether this error's Java class is, or extends,
536    /// `org.apache.kafka.common.errors.FetchSessionIdNotFoundException`.
537    fn is_fetch_session_id_not_found_error(&self) -> bool {
538        false
539    }
540
541    /// Whether this error's Java class is, or extends,
542    /// `org.apache.kafka.common.errors.FetchSessionTopicIdException`.
543    fn is_fetch_session_topic_id_error(&self) -> bool {
544        false
545    }
546
547    /// Whether this error's Java class is, or extends,
548    /// `org.apache.kafka.common.errors.GroupAuthorizationException`.
549    fn is_group_authorization_error(&self) -> bool {
550        false
551    }
552
553    /// Whether this error's Java class is, or extends,
554    /// `org.apache.kafka.common.errors.GroupDeletionFailedException`.
555    fn is_group_deletion_failed_error(&self) -> bool {
556        false
557    }
558
559    /// Whether this error's Java class is, or extends,
560    /// `org.apache.kafka.common.errors.GroupIdNotFoundException`.
561    fn is_group_id_not_found_error(&self) -> bool {
562        false
563    }
564
565    /// Whether this error's Java class is, or extends,
566    /// `org.apache.kafka.common.errors.GroupMaxSizeReachedException`.
567    fn is_group_max_size_reached_error(&self) -> bool {
568        false
569    }
570
571    /// Whether this error's Java class is, or extends,
572    /// `org.apache.kafka.common.errors.GroupNotEmptyException`.
573    fn is_group_not_empty_error(&self) -> bool {
574        false
575    }
576
577    /// Whether this error's Java class is, or extends,
578    /// `org.apache.kafka.common.errors.GroupSubscribedToTopicException`.
579    fn is_group_subscribed_to_topic_error(&self) -> bool {
580        false
581    }
582
583    /// Whether this error's Java class is, or extends,
584    /// `org.apache.kafka.common.errors.IllegalGenerationException`.
585    fn is_illegal_generation_error(&self) -> bool {
586        false
587    }
588
589    /// Whether this error's Java class is, or extends,
590    /// `org.apache.kafka.common.errors.IllegalSaslStateException`.
591    fn is_illegal_sasl_state_error(&self) -> bool {
592        false
593    }
594
595    /// Whether this error's Java class is, or extends,
596    /// `org.apache.kafka.common.errors.InconsistentClusterIdException`.
597    fn is_inconsistent_cluster_id_error(&self) -> bool {
598        false
599    }
600
601    /// Whether this error's Java class is, or extends,
602    /// `org.apache.kafka.common.errors.InconsistentGroupProtocolException`.
603    fn is_inconsistent_group_protocol_error(&self) -> bool {
604        false
605    }
606
607    /// Whether this error's Java class is, or extends,
608    /// `org.apache.kafka.common.errors.InconsistentTopicIdException`.
609    fn is_inconsistent_topic_id_error(&self) -> bool {
610        false
611    }
612
613    /// Whether this error's Java class is, or extends,
614    /// `org.apache.kafka.common.errors.InconsistentVoterSetException`.
615    fn is_inconsistent_voter_set_error(&self) -> bool {
616        false
617    }
618
619    /// Whether this error's Java class is, or extends,
620    /// `org.apache.kafka.common.errors.IneligibleReplicaException`.
621    fn is_ineligible_replica_error(&self) -> bool {
622        false
623    }
624
625    /// Whether this error's Java class is, or extends,
626    /// `org.apache.kafka.common.errors.InterruptException`.
627    fn is_interrupt_error(&self) -> bool {
628        false
629    }
630
631    /// Whether this error's Java class is, or extends,
632    /// `org.apache.kafka.common.errors.InvalidCommitOffsetSizeException`.
633    fn is_invalid_commit_offset_size_error(&self) -> bool {
634        false
635    }
636
637    /// Whether this error's Java class is, or extends,
638    /// `org.apache.kafka.common.errors.InvalidFetchSessionEpochException`.
639    fn is_invalid_fetch_session_epoch_error(&self) -> bool {
640        false
641    }
642
643    /// Whether this error's Java class is, or extends,
644    /// `org.apache.kafka.common.errors.InvalidFetchSizeException`.
645    fn is_invalid_fetch_size_error(&self) -> bool {
646        false
647    }
648
649    /// Whether this error's Java class is, or extends,
650    /// `org.apache.kafka.common.errors.InvalidGroupIdException`.
651    fn is_invalid_group_id_error(&self) -> bool {
652        false
653    }
654
655    /// Whether this error's Java class is, or extends,
656    /// `org.apache.kafka.common.errors.InvalidPartitionsException`.
657    fn is_invalid_partitions_error(&self) -> bool {
658        false
659    }
660
661    /// Whether this error's Java class is, or extends,
662    /// `org.apache.kafka.common.errors.InvalidPidMappingException`.
663    fn is_invalid_pid_mapping_error(&self) -> bool {
664        false
665    }
666
667    /// Whether this error's Java class is, or extends,
668    /// `org.apache.kafka.common.errors.InvalidPrincipalTypeException`.
669    fn is_invalid_principal_type_error(&self) -> bool {
670        false
671    }
672
673    /// Whether this error's Java class is, or extends,
674    /// `org.apache.kafka.common.errors.InvalidProducerEpochException`.
675    fn is_invalid_producer_epoch_error(&self) -> bool {
676        false
677    }
678
679    /// Whether this error's Java class is, or extends,
680    /// `org.apache.kafka.common.InvalidRecordException`.
681    fn is_invalid_record_error(&self) -> bool {
682        false
683    }
684
685    /// Whether this error's Java class is, or extends,
686    /// `org.apache.kafka.common.errors.InvalidRecordStateException`.
687    fn is_invalid_record_state_error(&self) -> bool {
688        false
689    }
690
691    /// Whether this error's Java class is, or extends,
692    /// `org.apache.kafka.common.errors.InvalidRegistrationException`.
693    fn is_invalid_registration_error(&self) -> bool {
694        false
695    }
696
697    /// Whether this error's Java class is, or extends,
698    /// `org.apache.kafka.common.errors.InvalidRegularExpression`.
699    fn is_invalid_regular_expression_error(&self) -> bool {
700        false
701    }
702
703    /// Whether this error's Java class is, or extends,
704    /// `org.apache.kafka.common.errors.InvalidReplicaAssignmentException`.
705    fn is_invalid_replica_assignment_error(&self) -> bool {
706        false
707    }
708
709    /// Whether this error's Java class is, or extends,
710    /// `org.apache.kafka.common.errors.InvalidReplicationFactorException`.
711    fn is_invalid_replication_factor_error(&self) -> bool {
712        false
713    }
714
715    /// Whether this error's Java class is, or extends,
716    /// `org.apache.kafka.common.errors.InvalidRequestException`.
717    fn is_invalid_request_error(&self) -> bool {
718        false
719    }
720
721    /// Whether this error's Java class is, or extends,
722    /// `org.apache.kafka.common.errors.InvalidRequiredAcksException`.
723    fn is_invalid_required_acks_error(&self) -> bool {
724        false
725    }
726
727    /// Whether this error's Java class is, or extends,
728    /// `org.apache.kafka.common.errors.InvalidSessionTimeoutException`.
729    fn is_invalid_session_timeout_error(&self) -> bool {
730        false
731    }
732
733    /// Whether this error's Java class is, or extends,
734    /// `org.apache.kafka.common.errors.InvalidShareSessionEpochException`.
735    fn is_invalid_share_session_epoch_error(&self) -> bool {
736        false
737    }
738
739    /// Whether this error's Java class is, or extends,
740    /// `org.apache.kafka.common.errors.InvalidTimestampException`.
741    fn is_invalid_timestamp_error(&self) -> bool {
742        false
743    }
744
745    /// Whether this error's Java class is, or extends,
746    /// `org.apache.kafka.common.errors.InvalidTopicException`.
747    fn is_invalid_topic_error(&self) -> bool {
748        false
749    }
750
751    /// Whether this error's Java class is, or extends,
752    /// `org.apache.kafka.common.errors.InvalidTxnStateException`.
753    fn is_invalid_txn_state_error(&self) -> bool {
754        false
755    }
756
757    /// Whether this error's Java class is, or extends,
758    /// `org.apache.kafka.common.errors.InvalidTxnTimeoutException`.
759    fn is_invalid_txn_timeout_error(&self) -> bool {
760        false
761    }
762
763    /// Whether this error's Java class is, or extends,
764    /// `org.apache.kafka.common.errors.InvalidUpdateVersionException`.
765    fn is_invalid_update_version_error(&self) -> bool {
766        false
767    }
768
769    /// Whether this error's Java class is, or extends,
770    /// `org.apache.kafka.common.errors.InvalidVoterKeyException`.
771    fn is_invalid_voter_key_error(&self) -> bool {
772        false
773    }
774
775    /// Whether this error's Java class is, or extends,
776    /// `org.apache.kafka.common.errors.KafkaStorageException`.
777    fn is_kafka_storage_error(&self) -> bool {
778        false
779    }
780
781    /// Whether this error's Java class is, or extends,
782    /// `org.apache.kafka.common.errors.LeaderNotAvailableException`.
783    fn is_leader_not_available_error(&self) -> bool {
784        false
785    }
786
787    /// Whether this error's Java class is, or extends,
788    /// `org.apache.kafka.common.errors.ListenerNotFoundException`.
789    fn is_listener_not_found_error(&self) -> bool {
790        false
791    }
792
793    /// Whether this error's Java class is, or extends,
794    /// `org.apache.kafka.common.errors.LogDirNotFoundException`.
795    fn is_log_dir_not_found_error(&self) -> bool {
796        false
797    }
798
799    /// Whether this error's Java class is, or extends,
800    /// `org.apache.kafka.common.errors.MemberIdRequiredException`.
801    fn is_member_id_required_error(&self) -> bool {
802        false
803    }
804
805    /// Whether this error's Java class is, or extends,
806    /// `org.apache.kafka.common.errors.MismatchedEndpointTypeException`.
807    fn is_mismatched_endpoint_type_error(&self) -> bool {
808        false
809    }
810
811    /// Whether this error's Java class is, or extends,
812    /// `org.apache.kafka.common.errors.NetworkException`.
813    fn is_network_error(&self) -> bool {
814        false
815    }
816
817    /// Whether this error's Java class is, or extends,
818    /// `org.apache.kafka.common.errors.NewLeaderElectedException`.
819    fn is_new_leader_elected_error(&self) -> bool {
820        false
821    }
822
823    /// Whether this error's Java class is, or extends,
824    /// `org.apache.kafka.common.errors.NoReassignmentInProgressException`.
825    fn is_no_reassignment_in_progress_error(&self) -> bool {
826        false
827    }
828
829    /// Whether this error's Java class is, or extends,
830    /// `org.apache.kafka.common.errors.NotControllerException`.
831    fn is_not_controller_error(&self) -> bool {
832        false
833    }
834
835    /// Whether this error's Java class is, or extends,
836    /// `org.apache.kafka.common.errors.NotCoordinatorException`.
837    fn is_not_coordinator_error(&self) -> bool {
838        false
839    }
840
841    /// Whether this error's Java class is, or extends,
842    /// `org.apache.kafka.common.errors.NotEnoughReplicasException`.
843    fn is_not_enough_replicas_error(&self) -> bool {
844        false
845    }
846
847    /// Whether this error's Java class is, or extends,
848    /// `org.apache.kafka.common.errors.NotEnoughReplicasAfterAppendException`.
849    fn is_not_enough_replicas_after_append_error(&self) -> bool {
850        false
851    }
852
853    /// Whether this error's Java class is, or extends,
854    /// `org.apache.kafka.common.errors.NotLeaderOrFollowerException`.
855    fn is_not_leader_or_follower_error(&self) -> bool {
856        false
857    }
858
859    /// Whether this error's Java class is, or extends,
860    /// `org.apache.kafka.common.errors.OffsetMetadataTooLarge`.
861    fn is_offset_metadata_too_large_error(&self) -> bool {
862        false
863    }
864
865    /// Whether this error's Java class is, or extends,
866    /// `org.apache.kafka.common.errors.OffsetMovedToTieredStorageException`.
867    fn is_offset_moved_to_tiered_storage_error(&self) -> bool {
868        false
869    }
870
871    /// Whether this error's Java class is, or extends,
872    /// `org.apache.kafka.common.errors.OffsetNotAvailableException`.
873    fn is_offset_not_available_error(&self) -> bool {
874        false
875    }
876
877    /// Whether this error's Java class is, or extends,
878    /// `org.apache.kafka.common.errors.OffsetOutOfRangeException`.
879    fn is_offset_out_of_range_error(&self) -> bool {
880        false
881    }
882
883    /// Whether this error's Java class is, or extends,
884    /// `org.apache.kafka.common.errors.OperationNotAttemptedException`.
885    fn is_operation_not_attempted_error(&self) -> bool {
886        false
887    }
888
889    /// Whether this error's Java class is, or extends,
890    /// `org.apache.kafka.common.errors.PolicyViolationException`.
891    fn is_policy_violation_error(&self) -> bool {
892        false
893    }
894
895    /// Whether this error's Java class is, or extends,
896    /// `org.apache.kafka.common.errors.PositionOutOfRangeException`.
897    fn is_position_out_of_range_error(&self) -> bool {
898        false
899    }
900
901    /// Whether this error's Java class is, or extends,
902    /// `org.apache.kafka.common.errors.PreferredLeaderNotAvailableException`.
903    fn is_preferred_leader_not_available_error(&self) -> bool {
904        false
905    }
906
907    /// Whether this error's Java class is, or extends,
908    /// `org.apache.kafka.common.errors.PrincipalDeserializationException`.
909    fn is_principal_deserialization_error(&self) -> bool {
910        false
911    }
912
913    /// Whether this error's Java class is, or extends,
914    /// `org.apache.kafka.common.errors.ProducerFencedException`.
915    fn is_producer_fenced_error(&self) -> bool {
916        false
917    }
918
919    /// Whether this error's Java class is, or extends,
920    /// `org.apache.kafka.common.metrics.QuotaViolationException`.
921    fn is_quota_violation_error(&self) -> bool {
922        false
923    }
924
925    /// Whether this error's Java class is, or extends,
926    /// `org.apache.kafka.common.errors.ReassignmentInProgressException`.
927    fn is_reassignment_in_progress_error(&self) -> bool {
928        false
929    }
930
931    /// Whether this error's Java class is, or extends,
932    /// `org.apache.kafka.common.errors.RebalanceInProgressException`.
933    fn is_rebalance_in_progress_error(&self) -> bool {
934        false
935    }
936
937    /// Whether this error's Java class is, or extends,
938    /// `org.apache.kafka.common.errors.RebootstrapRequiredException`.
939    fn is_rebootstrap_required_error(&self) -> bool {
940        false
941    }
942
943    /// Whether this error's Java class is, or extends,
944    /// `org.apache.kafka.common.errors.RecordBatchTooLargeException`.
945    fn is_record_batch_too_large_error(&self) -> bool {
946        false
947    }
948
949    /// Whether this error's Java class is, or extends,
950    /// `org.apache.kafka.common.errors.RecordDeserializationException`.
951    fn is_record_deserialization_error(&self) -> bool {
952        false
953    }
954
955    /// Whether this error's Java class is, or extends,
956    /// `org.apache.kafka.common.errors.RecordTooLargeException`.
957    fn is_record_too_large_error(&self) -> bool {
958        false
959    }
960
961    /// Whether this error's Java class is, or extends,
962    /// `org.apache.kafka.common.network.InvalidReceiveException`.
963    fn is_invalid_receive_error(&self) -> bool {
964        false
965    }
966
967    /// Whether this error's Java class is, or extends,
968    /// `org.apache.kafka.common.config.ConfigException`.
969    fn is_config_error(&self) -> bool {
970        false
971    }
972
973    /// Whether this error's Java class is, or extends,
974    /// `org.apache.kafka.clients.consumer.RetriableCommitFailedException`.
975    fn is_consumer_retriable_commit_failed_error(&self) -> bool {
976        false
977    }
978
979    /// Whether this error's Java class is, or extends,
980    /// `org.apache.kafka.clients.consumer.CommitFailedException`.
981    fn is_consumer_commit_failed_error(&self) -> bool {
982        false
983    }
984
985    /// Whether this error's Java class is, or extends,
986    /// `org.apache.kafka.clients.consumer.NoOffsetForPartitionException`.
987    fn is_consumer_no_offset_for_partition_error(&self) -> bool {
988        false
989    }
990
991    /// Whether this error's Java class is, or extends,
992    /// `org.apache.kafka.clients.consumer.LogTruncationException`.
993    fn is_consumer_log_truncation_error(&self) -> bool {
994        false
995    }
996
997    /// Whether this error's Java class is, or extends,
998    /// `org.apache.kafka.common.errors.ReplicaNotAvailableException`.
999    fn is_replica_not_available_error(&self) -> bool {
1000        false
1001    }
1002
1003    /// Whether this error's Java class is, or extends,
1004    /// `org.apache.kafka.common.errors.ResourceNotFoundException`.
1005    fn is_resource_not_found_error(&self) -> bool {
1006        false
1007    }
1008
1009    /// Whether this error's Java class is, or extends,
1010    /// `org.apache.kafka.common.errors.SaslAuthenticationException`.
1011    fn is_sasl_authentication_error(&self) -> bool {
1012        false
1013    }
1014
1015    /// Whether this error's Java class is, or extends,
1016    /// `org.apache.kafka.common.protocol.types.SchemaException`.
1017    fn is_schema_error(&self) -> bool {
1018        false
1019    }
1020
1021    /// Whether this error's Java class is, or extends,
1022    /// `org.apache.kafka.common.errors.SecurityDisabledException`.
1023    fn is_security_disabled_error(&self) -> bool {
1024        false
1025    }
1026
1027    /// Whether this error's Java class is, or extends,
1028    /// `org.apache.kafka.common.errors.ShareSessionLimitReachedException`.
1029    fn is_share_session_limit_reached_error(&self) -> bool {
1030        false
1031    }
1032
1033    /// Whether this error's Java class is, or extends,
1034    /// `org.apache.kafka.common.errors.ShareSessionNotFoundException`.
1035    fn is_share_session_not_found_error(&self) -> bool {
1036        false
1037    }
1038
1039    /// Whether this error's Java class is, or extends,
1040    /// `org.apache.kafka.common.errors.SnapshotNotFoundException`.
1041    fn is_snapshot_not_found_error(&self) -> bool {
1042        false
1043    }
1044
1045    /// Whether this error's Java class is, or extends,
1046    /// `org.apache.kafka.common.errors.SslAuthenticationException`.
1047    fn is_ssl_authentication_error(&self) -> bool {
1048        false
1049    }
1050
1051    /// Whether this error's Java class is, or extends,
1052    /// `org.apache.kafka.common.errors.StaleBrokerEpochException`.
1053    fn is_stale_broker_epoch_error(&self) -> bool {
1054        false
1055    }
1056
1057    /// Whether this error's Java class is, or extends,
1058    /// `org.apache.kafka.common.errors.StaleMemberEpochException`.
1059    fn is_stale_member_epoch_error(&self) -> bool {
1060        false
1061    }
1062
1063    /// Whether this error's Java class is, or extends,
1064    /// `org.apache.kafka.common.errors.StreamsInvalidTopologyException`.
1065    fn is_streams_invalid_topology_error(&self) -> bool {
1066        false
1067    }
1068
1069    /// Whether this error's Java class is, or extends,
1070    /// `org.apache.kafka.common.errors.StreamsInvalidTopologyEpochException`.
1071    fn is_streams_invalid_topology_epoch_error(&self) -> bool {
1072        false
1073    }
1074
1075    /// Whether this error's Java class is, or extends,
1076    /// `org.apache.kafka.common.errors.StreamsTopologyDescriptionUpdateFailedException`.
1077    fn is_streams_topology_description_update_failed_error(&self) -> bool {
1078        false
1079    }
1080
1081    /// Whether this error's Java class is, or extends,
1082    /// `org.apache.kafka.common.errors.StreamsTopologyFencedException`.
1083    fn is_streams_topology_fenced_error(&self) -> bool {
1084        false
1085    }
1086
1087    /// Whether this error's Java class is, or extends,
1088    /// `org.apache.kafka.common.errors.TelemetryTooLargeException`.
1089    fn is_telemetry_too_large_error(&self) -> bool {
1090        false
1091    }
1092
1093    /// Whether this error's Java class is, or extends,
1094    /// `org.apache.kafka.common.errors.ThrottlingQuotaExceededException`.
1095    fn is_throttling_quota_exceeded_error(&self) -> bool {
1096        false
1097    }
1098
1099    /// Whether this error's Java class is, or extends,
1100    /// `org.apache.kafka.common.errors.TopicAuthorizationException`.
1101    fn is_topic_authorization_error(&self) -> bool {
1102        false
1103    }
1104
1105    /// Whether this error's Java class is, or extends,
1106    /// `org.apache.kafka.common.errors.TopicDeletionDisabledException`.
1107    fn is_topic_deletion_disabled_error(&self) -> bool {
1108        false
1109    }
1110
1111    /// Whether this error's Java class is, or extends,
1112    /// `org.apache.kafka.common.errors.TopicExistsException`.
1113    fn is_topic_exists_error(&self) -> bool {
1114        false
1115    }
1116
1117    /// Whether this error's Java class is, or extends,
1118    /// `org.apache.kafka.common.errors.TransactionAbortableException`.
1119    fn is_transaction_abortable_error(&self) -> bool {
1120        false
1121    }
1122
1123    /// Whether this error's Java class is, or extends,
1124    /// `org.apache.kafka.common.errors.TransactionAbortedException`.
1125    fn is_transaction_aborted_error(&self) -> bool {
1126        false
1127    }
1128
1129    /// Whether this error's Java class is, or extends,
1130    /// `org.apache.kafka.common.errors.TransactionCoordinatorFencedException`.
1131    fn is_transaction_coordinator_fenced_error(&self) -> bool {
1132        false
1133    }
1134
1135    /// Whether this error's Java class is, or extends,
1136    /// `org.apache.kafka.common.errors.TransactionalIdAuthorizationException`.
1137    fn is_transactional_id_authorization_error(&self) -> bool {
1138        false
1139    }
1140
1141    /// Whether this error's Java class is, or extends,
1142    /// `org.apache.kafka.common.errors.TransactionalIdNotFoundException`.
1143    fn is_transactional_id_not_found_error(&self) -> bool {
1144        false
1145    }
1146
1147    /// Whether this error's Java class is, or extends,
1148    /// `org.apache.kafka.common.errors.UnacceptableCredentialException`.
1149    fn is_unacceptable_credential_error(&self) -> bool {
1150        false
1151    }
1152
1153    /// Whether this error's Java class is, or extends,
1154    /// `org.apache.kafka.common.errors.UnknownControllerIdException`.
1155    fn is_unknown_controller_id_error(&self) -> bool {
1156        false
1157    }
1158
1159    /// Whether this error's Java class is, or extends,
1160    /// `org.apache.kafka.common.errors.UnknownLeaderEpochException`.
1161    fn is_unknown_leader_epoch_error(&self) -> bool {
1162        false
1163    }
1164
1165    /// Whether this error's Java class is, or extends,
1166    /// `org.apache.kafka.common.errors.UnknownMemberIdException`.
1167    fn is_unknown_member_id_error(&self) -> bool {
1168        false
1169    }
1170
1171    /// Whether this error's Java class is, or extends,
1172    /// `org.apache.kafka.common.errors.UnknownProducerIdException`.
1173    fn is_unknown_producer_id_error(&self) -> bool {
1174        false
1175    }
1176
1177    /// Whether this error's Java class is, or extends,
1178    /// `org.apache.kafka.common.errors.UnknownServerException`.
1179    fn is_unknown_server_error(&self) -> bool {
1180        false
1181    }
1182
1183    /// Whether this error's Java class is, or extends,
1184    /// `org.apache.kafka.common.errors.UnknownSubscriptionIdException`.
1185    fn is_unknown_subscription_id_error(&self) -> bool {
1186        false
1187    }
1188
1189    /// Whether this error's Java class is, or extends,
1190    /// `org.apache.kafka.common.errors.UnknownTopicIdException`.
1191    fn is_unknown_topic_id_error(&self) -> bool {
1192        false
1193    }
1194
1195    /// Whether this error's Java class is, or extends,
1196    /// `org.apache.kafka.common.errors.UnknownTopicOrPartitionException`.
1197    fn is_unknown_topic_or_partition_error(&self) -> bool {
1198        false
1199    }
1200
1201    /// Whether this error's Java class is, or extends,
1202    /// `org.apache.kafka.common.errors.UnreleasedInstanceIdException`.
1203    fn is_unreleased_instance_id_error(&self) -> bool {
1204        false
1205    }
1206
1207    /// Whether this error's Java class is, or extends,
1208    /// `org.apache.kafka.common.errors.UnstableOffsetCommitException`.
1209    fn is_unstable_offset_commit_error(&self) -> bool {
1210        false
1211    }
1212
1213    /// Whether this error's Java class is, or extends,
1214    /// `org.apache.kafka.common.errors.UnsupportedAssignorException`.
1215    fn is_unsupported_assignor_error(&self) -> bool {
1216        false
1217    }
1218
1219    /// Whether this error's Java class is, or extends,
1220    /// `org.apache.kafka.common.errors.UnsupportedByAuthenticationException`.
1221    fn is_unsupported_by_authentication_error(&self) -> bool {
1222        false
1223    }
1224
1225    /// Whether this error's Java class is, or extends,
1226    /// `org.apache.kafka.common.errors.UnsupportedCompressionTypeException`.
1227    fn is_unsupported_compression_type_error(&self) -> bool {
1228        false
1229    }
1230
1231    /// Whether this error's Java class is, or extends,
1232    /// `org.apache.kafka.common.errors.UnsupportedEndpointTypeException`.
1233    fn is_unsupported_endpoint_type_error(&self) -> bool {
1234        false
1235    }
1236
1237    /// Whether this error's Java class is, or extends,
1238    /// `org.apache.kafka.common.errors.UnsupportedForMessageFormatException`.
1239    fn is_unsupported_for_message_format_error(&self) -> bool {
1240        false
1241    }
1242
1243    /// Whether this error's Java class is, or extends,
1244    /// `org.apache.kafka.common.errors.UnsupportedSaslMechanismException`.
1245    fn is_unsupported_sasl_mechanism_error(&self) -> bool {
1246        false
1247    }
1248
1249    /// Whether this error's Java class is, or extends,
1250    /// `org.apache.kafka.common.errors.UnsupportedVersionException`.
1251    ///
1252    /// Kafka 4.4's `common.internals.UnsupportedProtocolFieldException` extends
1253    /// it (as the `NoBatchedFindCoordinatorsException` /
1254    /// `NoBatchedOffsetFetchRequestException` nested in the request classes
1255    /// already did). None of those subclasses is public, so they share the one
1256    /// [`UnsupportedVersionError`] payload and only it answers `true`.
1257    fn is_unsupported_version_error(&self) -> bool {
1258        false
1259    }
1260
1261    /// Whether this error's Java class is, or extends,
1262    /// `org.apache.kafka.common.errors.VoterNotFoundException`.
1263    fn is_voter_not_found_error(&self) -> bool {
1264        false
1265    }
1266
1267    /// Whether this error's Java class is, or extends,
1268    /// `org.apache.kafka.common.errors.WakeupException`.
1269    fn is_wakeup_error(&self) -> bool {
1270        false
1271    }
1272}
1273
1274/// The protocol error code an error corresponds to.
1275///
1276/// **Mechanism, not API**, like [`ErrorHierarchy`]. Java's exceptions do not
1277/// store their code; `Errors` keeps a `CLASS_TO_ERROR` map and
1278/// `Errors.forException(t)` looks the class up in it
1279/// (`org.apache.kafka.common.protocol.Errors#forException`). This trait is that map inverted into a
1280/// per-type answer, which is the only form the compiler can check.
1281///
1282/// The default is [`Errors::UnknownServerError`], matching what
1283/// [`Error::error`] has always returned for payloads that carry no protocol
1284/// code — the generic `java.lang` errors and the client-side-only
1285/// `KafkaException` subclasses.
1286#[delegatable_trait]
1287pub(crate) trait ErrorCode {
1288    /// The protocol error code for this error's Java class.
1289    fn error(&self) -> Errors {
1290        Errors::UnknownServerError
1291    }
1292}
1293
1294/// The name of the error's own class, translating Java's
1295/// `getClass().getName()`.
1296///
1297/// **Mechanism, not API**, like [`ErrorMessage`]: it exists so
1298/// [`Errors::error_name`] can answer without matching on 138 codes a second
1299/// time. Callers use [`Errors::error_name`], which translates
1300/// `org.apache.kafka.common.protocol.Errors#exceptionName`.
1301///
1302/// Java returns the *fully qualified* class name
1303/// (`"org.apache.kafka.common.errors.UnknownServerException"`). Rust has no Java
1304/// package to report, so this returns the bare type name
1305/// (`"UnknownServerError"`) — the same string [`std::fmt::Display`] prefixes, which
1306/// is the translation of `Throwable.toString()`'s `getClass().getName()` and so
1307/// keeps the two consistent.
1308///
1309/// The method is **required**, with no default, for the same reason
1310/// [`ErrorMessage::message`] is: a wrong-but-plausible default would let a new
1311/// payload silently report the wrong class instead of failing to compile.
1312#[delegatable_trait]
1313pub(crate) trait ErrorName {
1314    /// The error's own type name, without a module path.
1315    fn name(&self) -> &'static str;
1316}
1317
1318/// Declares one Java exception class from `org.apache.kafka.common.errors`.
1319///
1320/// Generates the struct (message only), its `Display` (`"<TypeName>: <message>"`,
1321/// mirroring Java's `Throwable.toString()`), and the [`ErrorMessage`],
1322/// [`ErrorCode`] and [`ErrorHierarchy`] impls.
1323///
1324/// The `extends:` list is the class's Java `extends` chain, written as the
1325/// predicates it makes true. Everything omitted inherits the trait's `false`, so
1326/// the list is the whole statement of the type's ancestry and can be diffed
1327/// against the Java file directly:
1328///
1329/// ```text
1330/// NetworkException extends InvalidMetadataException extends RefreshRetriableException
1331///     extends RetriableException extends ApiException extends KafkaException
1332/// => extends: [is_kafka_error, is_api_error, is_retriable_error,
1333///              is_refresh_retriable_error, is_invalid_metadata_error]
1334/// ```
1335///
1336/// An optional `kind: <Type>,` (after `code:`) adds a crate-private field of that
1337/// type, starting at its `Default`, read with `kind()` and set with `with_kind()`.
1338/// It lets one public variant stand for a Java class *and* crate-private
1339/// subclasses of it that the public `Error` surface does not name — the case of
1340/// `UnsupportedVersionException` and `common.internals.UnsupportedProtocolFieldException`.
1341macro_rules! kafka_error_type {
1342    // No `code:` — the class has no entry in `Errors.java`, and walking its
1343    // superclasses (Java's `Errors.forException`) finds none either, so
1344    // `ErrorCode` takes its default of `Errors::UnknownServerError`.
1345    (
1346        $(#[$meta:meta])*
1347        $name:ident,
1348        extends: [$($predicate:ident),* $(,)?] $(,)?
1349    ) => {
1350        kafka_error_type! {
1351            $(#[$meta])*
1352            $name,
1353            code: $crate::common::protocol::Errors::UnknownServerError,
1354            extends: [$($predicate),*],
1355        }
1356    };
1357    (
1358        $(#[$meta:meta])*
1359        $name:ident,
1360        code: $code:expr,
1361        $(kind: $kind:ty,)?
1362        extends: [$($predicate:ident),* $(,)?] $(,)?
1363    ) => {
1364        $(#[$meta])*
1365        #[derive(Clone, Debug)]
1366        pub struct $name {
1367            message: String,
1368            /// The underlying cause, translating Java's `Throwable` `cause`.
1369            source: Option<Box<$crate::common::Error>>,
1370            $(
1371                /// Which crate-private Java subclass, if any, this value stands for.
1372                kind: $kind,
1373            )?
1374        }
1375
1376        $(
1377            impl $name {
1378                /// Which crate-private Java subclass, if any, this value stands for.
1379                pub(crate) fn kind(&self) -> $kind {
1380                    self.kind
1381                }
1382
1383                /// Returns this error marked as the given crate-private subclass.
1384                pub(crate) fn with_kind(mut self, kind: $kind) -> Self {
1385                    self.kind = kind;
1386                    self
1387                }
1388            }
1389        )?
1390
1391        impl $name {
1392            /// Create the error with the given message and no cause,
1393            /// mirroring Java's `(String message)` constructor.
1394            ///
1395            /// This keeps the plain name under CLAUDE.md §2: the dominant Java
1396            /// shape among the classes this macro declares is
1397            /// `(String message)` + `(String message, Throwable cause)`, whose
1398            /// parameter-name intersection is `{message}` — matched exactly by
1399            /// `(String message)`.
1400            pub fn new(message: impl Into<String>) -> Self {
1401                Self {
1402                    message: message.into(),
1403                    source: None,
1404                    $(kind: <$kind as ::core::default::Default>::default(),)?
1405                }
1406            }
1407
1408            /// Create the error with the given message and an underlying cause,
1409            /// mirroring Java's `(String message, Throwable cause)` constructor.
1410            ///
1411            /// Suffixed with the one parameter beyond the `{message}`
1412            /// intersection (CLAUDE.md §2) — see [`new`](Self::new).
1413            pub fn with_source(message: impl Into<String>, source: $crate::common::Error) -> Self {
1414                Self {
1415                    message: message.into(),
1416                    source: Some(Box::new(source)),
1417                    $(kind: <$kind as ::core::default::Default>::default(),)?
1418                }
1419            }
1420
1421            /// Create the error with the default message for its error code,
1422            /// mirroring Java's `Errors.exception()`.
1423            ///
1424            /// Not a constructor overload, so CLAUDE.md §2's suffixing does not
1425            /// apply: it translates the `Errors` static factory, which fills in
1426            /// `Errors.message()` and has no Java constructor counterpart.
1427            pub fn with_default_message() -> Self {
1428                Self::new($code.message())
1429            }
1430
1431            /// The error message.
1432            pub fn message(&self) -> &str {
1433                &self.message
1434            }
1435
1436            /// The underlying cause, if any. Mirrors Java's `getCause()`.
1437            pub fn source(&self) -> Option<&$crate::common::Error> {
1438                self.source.as_deref()
1439            }
1440        }
1441
1442        impl $crate::common::error::ErrorSource for $name {
1443            fn source(&self) -> Option<&$crate::common::Error> {
1444                self.source.as_deref()
1445            }
1446        }
1447
1448        // The inherent `source()` above shadows both this and
1449        // `ErrorSource::source` for method-call syntax, so `e.source()` yields the
1450        // typed `Option<&Error>` while `StdError::source(&e)` gives the `dyn` view.
1451        impl ::std::error::Error for $name {
1452            fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
1453                self.source
1454                    .as_deref()
1455                    .map(|e| e as &(dyn ::std::error::Error + 'static))
1456            }
1457        }
1458
1459        impl ::std::fmt::Display for $name {
1460            fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
1461                write!(f, "{}: {}", stringify!($name), self.message)
1462            }
1463        }
1464
1465        impl $crate::common::error::ErrorMessage for $name {
1466            fn message(&self) -> &str {
1467                &self.message
1468            }
1469        }
1470
1471        impl $crate::common::error::ErrorName for $name {
1472            fn name(&self) -> &'static str {
1473                stringify!($name)
1474            }
1475        }
1476
1477        impl $crate::common::error::ErrorCode for $name {
1478            fn error(&self) -> $crate::common::protocol::Errors {
1479                $code
1480            }
1481        }
1482
1483        impl $crate::common::error::ErrorHierarchy for $name {
1484            $(
1485                fn $predicate(&self) -> bool {
1486                    true
1487                }
1488            )*
1489        }
1490    };
1491}
1492
1493pub(crate) use kafka_error_type;
1494
1495/// The message an error carries, translating Java's `Throwable.getMessage()`.
1496///
1497/// **Mechanism, not API**, like [`ErrorHierarchy`]: it exists so [`Error`] can
1498/// delegate [`Error::message`] to the variant's payload instead of matching.
1499/// Callers use [`Error::message`].
1500///
1501/// Distinct from [`std::fmt::Display`], which translates `Throwable.toString()` —
1502/// Java renders that as `getClass().getName() + ": " + getLocalizedMessage()`,
1503/// so `Display` prefixes the class name and may append subclass state (the
1504/// unauthorized topics, say) while this returns the bare message. Both are
1505/// pinned by tests; do not collapse them.
1506///
1507/// The method is **required**, with no default. There is no `&str` equivalent
1508/// of the predicates' `false`, and defaulting to `""` would reintroduce exactly
1509/// what this replaces: a new payload silently getting an empty message instead
1510/// of a compile error.
1511#[delegatable_trait]
1512pub(crate) trait ErrorMessage {
1513    /// The error message, without the class-name prefix `Display` adds.
1514    fn message(&self) -> &str;
1515}
1516
1517/// The error that caused this one, translating Java's `Throwable.getCause()`.
1518///
1519/// **Mechanism, not API**, like [`ErrorMessage`]: it exists so [`Error`] can
1520/// delegate [`Error::source`] to the variant's payload instead of matching.
1521/// Callers use [`Error::source`], or [`std::error::Error::source`] for the
1522/// standard-library view.
1523///
1524/// `getCause()` is declared on `java.lang.Throwable`, so **every** exception has
1525/// a cause slot — not just `KafkaException`. Accordingly every error class in
1526/// this crate carries one, and every one answers here. Whether a class lets a
1527/// caller *set* it follows Java: 92 of the 150 `common.errors` classes expose a
1528/// `Throwable cause` constructor, and the rest inherit an always-null cause.
1529///
1530/// The method defaults to `None` — unlike [`ErrorMessage::message`], `None` is a
1531/// legitimate answer (Java's default cause is null), so a payload that genuinely
1532/// has no cause slot is not forced to state one.
1533#[delegatable_trait]
1534pub(crate) trait ErrorSource {
1535    /// The underlying cause, if any. Mirrors Java's `Throwable.getCause()`.
1536    ///
1537    /// The bare `Error` (not `crate::common::Error`) is deliberate:
1538    /// `#[delegatable_trait]` copies this signature verbatim into the generated
1539    /// `ambassador_impl_ErrorSource` macro, and a `crate::` path inside a macro
1540    /// definition resolves against the *expansion* site
1541    /// (clippy::crate_in_macro_def). So every module that delegates this trait
1542    /// imports `Error`, exactly as the modules delegating [`ErrorCode`] import
1543    /// `Errors`.
1544    fn source(&self) -> Option<&Error> {
1545        None
1546    }
1547}
1548
1549// ---------------------------------------------------------------------------
1550// Boxed payloads
1551// ---------------------------------------------------------------------------
1552//
1553// NOTE: every predicate must be forwarded here. A trait method added without
1554// a matching line below silently falls back to the default (`false`) for any
1555// boxed payload — `ConsumerLogTruncation` regressed exactly that way.
1556//
1557// A variant may box its payload to keep `Error` small (see
1558// [`Error::ConsumerLogTruncation`]). Ambassador forwards to the payload by value-typed
1559// method call, so the box itself has to implement the traits — deref coercion
1560// does not satisfy a trait bound.
1561
1562impl<T: ErrorSource + ?Sized> ErrorSource for Box<T> {
1563    fn source(&self) -> Option<&Error> {
1564        (**self).source()
1565    }
1566}
1567
1568impl<T: ErrorHierarchy + ?Sized> ErrorHierarchy for Box<T> {
1569    fn is_kafka_error(&self) -> bool {
1570        (**self).is_kafka_error()
1571    }
1572    fn is_api_error(&self) -> bool {
1573        (**self).is_api_error()
1574    }
1575    fn is_retriable_error(&self) -> bool {
1576        (**self).is_retriable_error()
1577    }
1578    fn is_refresh_retriable_error(&self) -> bool {
1579        (**self).is_refresh_retriable_error()
1580    }
1581    fn is_timeout_error(&self) -> bool {
1582        (**self).is_timeout_error()
1583    }
1584    fn is_invalid_metadata_error(&self) -> bool {
1585        (**self).is_invalid_metadata_error()
1586    }
1587    fn is_invalid_configuration_error(&self) -> bool {
1588        (**self).is_invalid_configuration_error()
1589    }
1590    fn is_application_recoverable_error(&self) -> bool {
1591        (**self).is_application_recoverable_error()
1592    }
1593    fn is_invalid_offset_error(&self) -> bool {
1594        (**self).is_invalid_offset_error()
1595    }
1596    fn is_consumer_invalid_offset_error(&self) -> bool {
1597        (**self).is_consumer_invalid_offset_error()
1598    }
1599    fn is_consumer_offset_out_of_range_error(&self) -> bool {
1600        (**self).is_consumer_offset_out_of_range_error()
1601    }
1602    fn is_out_of_order_sequence_error(&self) -> bool {
1603        (**self).is_out_of_order_sequence_error()
1604    }
1605    fn is_serialization_error(&self) -> bool {
1606        (**self).is_serialization_error()
1607    }
1608    fn is_authentication_error(&self) -> bool {
1609        (**self).is_authentication_error()
1610    }
1611    fn is_authorization_error(&self) -> bool {
1612        (**self).is_authorization_error()
1613    }
1614    fn is_local_illegal_argument_error(&self) -> bool {
1615        (**self).is_local_illegal_argument_error()
1616    }
1617    fn is_local_illegal_state_error(&self) -> bool {
1618        (**self).is_local_illegal_state_error()
1619    }
1620    fn is_local_concurrent_modification_error(&self) -> bool {
1621        (**self).is_local_concurrent_modification_error()
1622    }
1623    fn is_local_timeout_error(&self) -> bool {
1624        (**self).is_local_timeout_error()
1625    }
1626    fn is_local_unsupported_operation_error(&self) -> bool {
1627        (**self).is_local_unsupported_operation_error()
1628    }
1629    fn is_local_callback_error(&self) -> bool {
1630        (**self).is_local_callback_error()
1631    }
1632    fn is_authorizer_not_ready_error(&self) -> bool {
1633        (**self).is_authorizer_not_ready_error()
1634    }
1635    fn is_bootstrap_resolution_error(&self) -> bool {
1636        (**self).is_bootstrap_resolution_error()
1637    }
1638    fn is_broker_id_not_registered_error(&self) -> bool {
1639        (**self).is_broker_id_not_registered_error()
1640    }
1641    fn is_broker_not_available_error(&self) -> bool {
1642        (**self).is_broker_not_available_error()
1643    }
1644    fn is_producer_buffer_exhausted_error(&self) -> bool {
1645        (**self).is_producer_buffer_exhausted_error()
1646    }
1647    fn is_cluster_authorization_error(&self) -> bool {
1648        (**self).is_cluster_authorization_error()
1649    }
1650    fn is_concurrent_transactions_error(&self) -> bool {
1651        (**self).is_concurrent_transactions_error()
1652    }
1653    fn is_controller_id_not_registered_error(&self) -> bool {
1654        (**self).is_controller_id_not_registered_error()
1655    }
1656    fn is_controller_moved_error(&self) -> bool {
1657        (**self).is_controller_moved_error()
1658    }
1659    fn is_coordinator_load_in_progress_error(&self) -> bool {
1660        (**self).is_coordinator_load_in_progress_error()
1661    }
1662    fn is_coordinator_not_available_error(&self) -> bool {
1663        (**self).is_coordinator_not_available_error()
1664    }
1665    fn is_correlation_id_mismatch_error(&self) -> bool {
1666        (**self).is_correlation_id_mismatch_error()
1667    }
1668    fn is_corrupt_record_error(&self) -> bool {
1669        (**self).is_corrupt_record_error()
1670    }
1671    fn is_delegation_token_authorization_error(&self) -> bool {
1672        (**self).is_delegation_token_authorization_error()
1673    }
1674    fn is_delegation_token_disabled_error(&self) -> bool {
1675        (**self).is_delegation_token_disabled_error()
1676    }
1677    fn is_delegation_token_expired_error(&self) -> bool {
1678        (**self).is_delegation_token_expired_error()
1679    }
1680    fn is_delegation_token_not_found_error(&self) -> bool {
1681        (**self).is_delegation_token_not_found_error()
1682    }
1683    fn is_delegation_token_owner_mismatch_error(&self) -> bool {
1684        (**self).is_delegation_token_owner_mismatch_error()
1685    }
1686    fn is_disconnect_error(&self) -> bool {
1687        (**self).is_disconnect_error()
1688    }
1689    fn is_duplicate_broker_registration_error(&self) -> bool {
1690        (**self).is_duplicate_broker_registration_error()
1691    }
1692    fn is_duplicate_resource_error(&self) -> bool {
1693        (**self).is_duplicate_resource_error()
1694    }
1695    fn is_duplicate_sequence_error(&self) -> bool {
1696        (**self).is_duplicate_sequence_error()
1697    }
1698    fn is_duplicate_voter_error(&self) -> bool {
1699        (**self).is_duplicate_voter_error()
1700    }
1701    fn is_election_not_needed_error(&self) -> bool {
1702        (**self).is_election_not_needed_error()
1703    }
1704    fn is_eligible_leaders_not_available_error(&self) -> bool {
1705        (**self).is_eligible_leaders_not_available_error()
1706    }
1707    fn is_feature_update_failed_error(&self) -> bool {
1708        (**self).is_feature_update_failed_error()
1709    }
1710    fn is_fenced_instance_id_error(&self) -> bool {
1711        (**self).is_fenced_instance_id_error()
1712    }
1713    fn is_fenced_leader_epoch_error(&self) -> bool {
1714        (**self).is_fenced_leader_epoch_error()
1715    }
1716    fn is_fenced_member_epoch_error(&self) -> bool {
1717        (**self).is_fenced_member_epoch_error()
1718    }
1719    fn is_fenced_state_epoch_error(&self) -> bool {
1720        (**self).is_fenced_state_epoch_error()
1721    }
1722    fn is_fetch_session_id_not_found_error(&self) -> bool {
1723        (**self).is_fetch_session_id_not_found_error()
1724    }
1725    fn is_fetch_session_topic_id_error(&self) -> bool {
1726        (**self).is_fetch_session_topic_id_error()
1727    }
1728    fn is_group_authorization_error(&self) -> bool {
1729        (**self).is_group_authorization_error()
1730    }
1731    fn is_group_deletion_failed_error(&self) -> bool {
1732        (**self).is_group_deletion_failed_error()
1733    }
1734    fn is_group_id_not_found_error(&self) -> bool {
1735        (**self).is_group_id_not_found_error()
1736    }
1737    fn is_group_max_size_reached_error(&self) -> bool {
1738        (**self).is_group_max_size_reached_error()
1739    }
1740    fn is_group_not_empty_error(&self) -> bool {
1741        (**self).is_group_not_empty_error()
1742    }
1743    fn is_group_subscribed_to_topic_error(&self) -> bool {
1744        (**self).is_group_subscribed_to_topic_error()
1745    }
1746    fn is_illegal_generation_error(&self) -> bool {
1747        (**self).is_illegal_generation_error()
1748    }
1749    fn is_illegal_sasl_state_error(&self) -> bool {
1750        (**self).is_illegal_sasl_state_error()
1751    }
1752    fn is_inconsistent_cluster_id_error(&self) -> bool {
1753        (**self).is_inconsistent_cluster_id_error()
1754    }
1755    fn is_inconsistent_group_protocol_error(&self) -> bool {
1756        (**self).is_inconsistent_group_protocol_error()
1757    }
1758    fn is_inconsistent_topic_id_error(&self) -> bool {
1759        (**self).is_inconsistent_topic_id_error()
1760    }
1761    fn is_inconsistent_voter_set_error(&self) -> bool {
1762        (**self).is_inconsistent_voter_set_error()
1763    }
1764    fn is_ineligible_replica_error(&self) -> bool {
1765        (**self).is_ineligible_replica_error()
1766    }
1767    fn is_interrupt_error(&self) -> bool {
1768        (**self).is_interrupt_error()
1769    }
1770    fn is_invalid_commit_offset_size_error(&self) -> bool {
1771        (**self).is_invalid_commit_offset_size_error()
1772    }
1773    fn is_invalid_fetch_session_epoch_error(&self) -> bool {
1774        (**self).is_invalid_fetch_session_epoch_error()
1775    }
1776    fn is_invalid_fetch_size_error(&self) -> bool {
1777        (**self).is_invalid_fetch_size_error()
1778    }
1779    fn is_invalid_group_id_error(&self) -> bool {
1780        (**self).is_invalid_group_id_error()
1781    }
1782    fn is_invalid_partitions_error(&self) -> bool {
1783        (**self).is_invalid_partitions_error()
1784    }
1785    fn is_invalid_pid_mapping_error(&self) -> bool {
1786        (**self).is_invalid_pid_mapping_error()
1787    }
1788    fn is_invalid_principal_type_error(&self) -> bool {
1789        (**self).is_invalid_principal_type_error()
1790    }
1791    fn is_invalid_producer_epoch_error(&self) -> bool {
1792        (**self).is_invalid_producer_epoch_error()
1793    }
1794    fn is_invalid_record_error(&self) -> bool {
1795        (**self).is_invalid_record_error()
1796    }
1797    fn is_invalid_record_state_error(&self) -> bool {
1798        (**self).is_invalid_record_state_error()
1799    }
1800    fn is_invalid_registration_error(&self) -> bool {
1801        (**self).is_invalid_registration_error()
1802    }
1803    fn is_invalid_regular_expression_error(&self) -> bool {
1804        (**self).is_invalid_regular_expression_error()
1805    }
1806    fn is_invalid_replica_assignment_error(&self) -> bool {
1807        (**self).is_invalid_replica_assignment_error()
1808    }
1809    fn is_invalid_replication_factor_error(&self) -> bool {
1810        (**self).is_invalid_replication_factor_error()
1811    }
1812    fn is_invalid_request_error(&self) -> bool {
1813        (**self).is_invalid_request_error()
1814    }
1815    fn is_invalid_required_acks_error(&self) -> bool {
1816        (**self).is_invalid_required_acks_error()
1817    }
1818    fn is_invalid_session_timeout_error(&self) -> bool {
1819        (**self).is_invalid_session_timeout_error()
1820    }
1821    fn is_invalid_share_session_epoch_error(&self) -> bool {
1822        (**self).is_invalid_share_session_epoch_error()
1823    }
1824    fn is_invalid_timestamp_error(&self) -> bool {
1825        (**self).is_invalid_timestamp_error()
1826    }
1827    fn is_invalid_topic_error(&self) -> bool {
1828        (**self).is_invalid_topic_error()
1829    }
1830    fn is_invalid_txn_state_error(&self) -> bool {
1831        (**self).is_invalid_txn_state_error()
1832    }
1833    fn is_invalid_txn_timeout_error(&self) -> bool {
1834        (**self).is_invalid_txn_timeout_error()
1835    }
1836    fn is_invalid_update_version_error(&self) -> bool {
1837        (**self).is_invalid_update_version_error()
1838    }
1839    fn is_invalid_voter_key_error(&self) -> bool {
1840        (**self).is_invalid_voter_key_error()
1841    }
1842    fn is_kafka_storage_error(&self) -> bool {
1843        (**self).is_kafka_storage_error()
1844    }
1845    fn is_leader_not_available_error(&self) -> bool {
1846        (**self).is_leader_not_available_error()
1847    }
1848    fn is_listener_not_found_error(&self) -> bool {
1849        (**self).is_listener_not_found_error()
1850    }
1851    fn is_log_dir_not_found_error(&self) -> bool {
1852        (**self).is_log_dir_not_found_error()
1853    }
1854    fn is_member_id_required_error(&self) -> bool {
1855        (**self).is_member_id_required_error()
1856    }
1857    fn is_mismatched_endpoint_type_error(&self) -> bool {
1858        (**self).is_mismatched_endpoint_type_error()
1859    }
1860    fn is_network_error(&self) -> bool {
1861        (**self).is_network_error()
1862    }
1863    fn is_new_leader_elected_error(&self) -> bool {
1864        (**self).is_new_leader_elected_error()
1865    }
1866    fn is_no_reassignment_in_progress_error(&self) -> bool {
1867        (**self).is_no_reassignment_in_progress_error()
1868    }
1869    fn is_not_controller_error(&self) -> bool {
1870        (**self).is_not_controller_error()
1871    }
1872    fn is_not_coordinator_error(&self) -> bool {
1873        (**self).is_not_coordinator_error()
1874    }
1875    fn is_not_enough_replicas_error(&self) -> bool {
1876        (**self).is_not_enough_replicas_error()
1877    }
1878    fn is_not_enough_replicas_after_append_error(&self) -> bool {
1879        (**self).is_not_enough_replicas_after_append_error()
1880    }
1881    fn is_not_leader_or_follower_error(&self) -> bool {
1882        (**self).is_not_leader_or_follower_error()
1883    }
1884    fn is_offset_metadata_too_large_error(&self) -> bool {
1885        (**self).is_offset_metadata_too_large_error()
1886    }
1887    fn is_offset_moved_to_tiered_storage_error(&self) -> bool {
1888        (**self).is_offset_moved_to_tiered_storage_error()
1889    }
1890    fn is_offset_not_available_error(&self) -> bool {
1891        (**self).is_offset_not_available_error()
1892    }
1893    fn is_offset_out_of_range_error(&self) -> bool {
1894        (**self).is_offset_out_of_range_error()
1895    }
1896    fn is_operation_not_attempted_error(&self) -> bool {
1897        (**self).is_operation_not_attempted_error()
1898    }
1899    fn is_policy_violation_error(&self) -> bool {
1900        (**self).is_policy_violation_error()
1901    }
1902    fn is_position_out_of_range_error(&self) -> bool {
1903        (**self).is_position_out_of_range_error()
1904    }
1905    fn is_preferred_leader_not_available_error(&self) -> bool {
1906        (**self).is_preferred_leader_not_available_error()
1907    }
1908    fn is_principal_deserialization_error(&self) -> bool {
1909        (**self).is_principal_deserialization_error()
1910    }
1911    fn is_producer_fenced_error(&self) -> bool {
1912        (**self).is_producer_fenced_error()
1913    }
1914    fn is_quota_violation_error(&self) -> bool {
1915        (**self).is_quota_violation_error()
1916    }
1917    fn is_reassignment_in_progress_error(&self) -> bool {
1918        (**self).is_reassignment_in_progress_error()
1919    }
1920    fn is_rebalance_in_progress_error(&self) -> bool {
1921        (**self).is_rebalance_in_progress_error()
1922    }
1923    fn is_rebootstrap_required_error(&self) -> bool {
1924        (**self).is_rebootstrap_required_error()
1925    }
1926    fn is_record_batch_too_large_error(&self) -> bool {
1927        (**self).is_record_batch_too_large_error()
1928    }
1929    fn is_record_deserialization_error(&self) -> bool {
1930        (**self).is_record_deserialization_error()
1931    }
1932    fn is_record_too_large_error(&self) -> bool {
1933        (**self).is_record_too_large_error()
1934    }
1935    fn is_invalid_receive_error(&self) -> bool {
1936        (**self).is_invalid_receive_error()
1937    }
1938    fn is_config_error(&self) -> bool {
1939        (**self).is_config_error()
1940    }
1941    fn is_consumer_retriable_commit_failed_error(&self) -> bool {
1942        (**self).is_consumer_retriable_commit_failed_error()
1943    }
1944    fn is_consumer_commit_failed_error(&self) -> bool {
1945        (**self).is_consumer_commit_failed_error()
1946    }
1947    fn is_consumer_no_offset_for_partition_error(&self) -> bool {
1948        (**self).is_consumer_no_offset_for_partition_error()
1949    }
1950    fn is_consumer_log_truncation_error(&self) -> bool {
1951        (**self).is_consumer_log_truncation_error()
1952    }
1953    fn is_replica_not_available_error(&self) -> bool {
1954        (**self).is_replica_not_available_error()
1955    }
1956    fn is_resource_not_found_error(&self) -> bool {
1957        (**self).is_resource_not_found_error()
1958    }
1959    fn is_sasl_authentication_error(&self) -> bool {
1960        (**self).is_sasl_authentication_error()
1961    }
1962    fn is_schema_error(&self) -> bool {
1963        (**self).is_schema_error()
1964    }
1965    fn is_security_disabled_error(&self) -> bool {
1966        (**self).is_security_disabled_error()
1967    }
1968    fn is_share_session_limit_reached_error(&self) -> bool {
1969        (**self).is_share_session_limit_reached_error()
1970    }
1971    fn is_share_session_not_found_error(&self) -> bool {
1972        (**self).is_share_session_not_found_error()
1973    }
1974    fn is_snapshot_not_found_error(&self) -> bool {
1975        (**self).is_snapshot_not_found_error()
1976    }
1977    fn is_ssl_authentication_error(&self) -> bool {
1978        (**self).is_ssl_authentication_error()
1979    }
1980    fn is_stale_broker_epoch_error(&self) -> bool {
1981        (**self).is_stale_broker_epoch_error()
1982    }
1983    fn is_stale_member_epoch_error(&self) -> bool {
1984        (**self).is_stale_member_epoch_error()
1985    }
1986    fn is_streams_invalid_topology_error(&self) -> bool {
1987        (**self).is_streams_invalid_topology_error()
1988    }
1989    fn is_streams_invalid_topology_epoch_error(&self) -> bool {
1990        (**self).is_streams_invalid_topology_epoch_error()
1991    }
1992    fn is_streams_topology_description_update_failed_error(&self) -> bool {
1993        (**self).is_streams_topology_description_update_failed_error()
1994    }
1995    fn is_streams_topology_fenced_error(&self) -> bool {
1996        (**self).is_streams_topology_fenced_error()
1997    }
1998    fn is_telemetry_too_large_error(&self) -> bool {
1999        (**self).is_telemetry_too_large_error()
2000    }
2001    fn is_throttling_quota_exceeded_error(&self) -> bool {
2002        (**self).is_throttling_quota_exceeded_error()
2003    }
2004    fn is_topic_authorization_error(&self) -> bool {
2005        (**self).is_topic_authorization_error()
2006    }
2007    fn is_topic_deletion_disabled_error(&self) -> bool {
2008        (**self).is_topic_deletion_disabled_error()
2009    }
2010    fn is_topic_exists_error(&self) -> bool {
2011        (**self).is_topic_exists_error()
2012    }
2013    fn is_transaction_abortable_error(&self) -> bool {
2014        (**self).is_transaction_abortable_error()
2015    }
2016    fn is_transaction_aborted_error(&self) -> bool {
2017        (**self).is_transaction_aborted_error()
2018    }
2019    fn is_transaction_coordinator_fenced_error(&self) -> bool {
2020        (**self).is_transaction_coordinator_fenced_error()
2021    }
2022    fn is_transactional_id_authorization_error(&self) -> bool {
2023        (**self).is_transactional_id_authorization_error()
2024    }
2025    fn is_transactional_id_not_found_error(&self) -> bool {
2026        (**self).is_transactional_id_not_found_error()
2027    }
2028    fn is_unacceptable_credential_error(&self) -> bool {
2029        (**self).is_unacceptable_credential_error()
2030    }
2031    fn is_unknown_controller_id_error(&self) -> bool {
2032        (**self).is_unknown_controller_id_error()
2033    }
2034    fn is_unknown_leader_epoch_error(&self) -> bool {
2035        (**self).is_unknown_leader_epoch_error()
2036    }
2037    fn is_unknown_member_id_error(&self) -> bool {
2038        (**self).is_unknown_member_id_error()
2039    }
2040    fn is_unknown_producer_id_error(&self) -> bool {
2041        (**self).is_unknown_producer_id_error()
2042    }
2043    fn is_unknown_server_error(&self) -> bool {
2044        (**self).is_unknown_server_error()
2045    }
2046    fn is_unknown_subscription_id_error(&self) -> bool {
2047        (**self).is_unknown_subscription_id_error()
2048    }
2049    fn is_unknown_topic_id_error(&self) -> bool {
2050        (**self).is_unknown_topic_id_error()
2051    }
2052    fn is_unknown_topic_or_partition_error(&self) -> bool {
2053        (**self).is_unknown_topic_or_partition_error()
2054    }
2055    fn is_unreleased_instance_id_error(&self) -> bool {
2056        (**self).is_unreleased_instance_id_error()
2057    }
2058    fn is_unstable_offset_commit_error(&self) -> bool {
2059        (**self).is_unstable_offset_commit_error()
2060    }
2061    fn is_unsupported_assignor_error(&self) -> bool {
2062        (**self).is_unsupported_assignor_error()
2063    }
2064    fn is_unsupported_by_authentication_error(&self) -> bool {
2065        (**self).is_unsupported_by_authentication_error()
2066    }
2067    fn is_unsupported_compression_type_error(&self) -> bool {
2068        (**self).is_unsupported_compression_type_error()
2069    }
2070    fn is_unsupported_endpoint_type_error(&self) -> bool {
2071        (**self).is_unsupported_endpoint_type_error()
2072    }
2073    fn is_unsupported_for_message_format_error(&self) -> bool {
2074        (**self).is_unsupported_for_message_format_error()
2075    }
2076    fn is_unsupported_sasl_mechanism_error(&self) -> bool {
2077        (**self).is_unsupported_sasl_mechanism_error()
2078    }
2079    fn is_unsupported_version_error(&self) -> bool {
2080        (**self).is_unsupported_version_error()
2081    }
2082    fn is_voter_not_found_error(&self) -> bool {
2083        (**self).is_voter_not_found_error()
2084    }
2085    fn is_wakeup_error(&self) -> bool {
2086        (**self).is_wakeup_error()
2087    }
2088}
2089
2090impl<T: ErrorMessage + ?Sized> ErrorMessage for Box<T> {
2091    fn message(&self) -> &str {
2092        (**self).message()
2093    }
2094}
2095
2096impl<T: ErrorCode + ?Sized> ErrorCode for Box<T> {
2097    fn error(&self) -> Errors {
2098        (**self).error()
2099    }
2100}
2101
2102impl<T: ErrorName + ?Sized> ErrorName for Box<T> {
2103    fn name(&self) -> &'static str {
2104        (**self).name()
2105    }
2106}
2107
2108// ---------------------------------------------------------------------------
2109// Specific error structs — correspond to Java error subclasses
2110// ---------------------------------------------------------------------------
2111
2112/// Declares a message-only error struct — one Java class that carries nothing
2113/// but its message.
2114///
2115/// Java gives each of these its own class, which is exactly what
2116/// `#[enum_dispatch]` requires: the payload type answers the hierarchy
2117/// predicates, so `Error::Timeout` and `Error::Wakeup` cannot both carry a
2118/// `String`. The generated `Display` renders as `"<TypeName>: <message>"`,
2119/// preserving the strings the previous hand-written `Display` produced.
2120///
2121/// Every path in the expansion is `$crate`-qualified, as in
2122/// [`kafka_error_type`], so an invoking file needs nothing in scope but the
2123/// macro itself. The five JDK `Local*` classes each live in their own file per
2124/// CLAUDE.md §2 and invoke this from there.
2125///
2126/// # Constructors deliberately not modelled
2127///
2128/// The five classes stand in for JDK types (`java.lang.IllegalStateException`,
2129/// `java.lang.IllegalArgumentException`,
2130/// `java.lang.UnsupportedOperationException`,
2131/// `java.util.ConcurrentModificationException`,
2132/// `java.util.concurrent.TimeoutException`), each of which really declares all
2133/// four of `()`, `(String)`, `(Throwable)`, `(String, Throwable)`. Under
2134/// CLAUDE.md §2 the no-arg form would own the plain `new` and the message form
2135/// would become `with_message`.
2136///
2137/// They are not modelled, and `new` keeps the message form, for two reasons:
2138///
2139///   - These are not translated Kafka classes but minimal stand-ins for classes
2140///     outside the repository (CLAUDE.md §1) — hence the macro's name. A
2141///     null-message constructor and a cause-only constructor would be public API
2142///     with no caller and no Kafka contract behind them (DoD #7).
2143///   - [`kafka_error_type`] cannot follow suit: it declares 145 classes from one
2144///     body, and only ~19 of their Java counterparts have a no-arg constructor.
2145///     Were `new` to mean the no-arg form here and the message form there,
2146///     `SomeError::new("msg")` would compile or not depending on which macro
2147///     declared the class, with nothing at the call site to say which.
2148macro_rules! message_only_error {
2149    ($(#[$meta:meta])* $name:ident) => {
2150        $(#[$meta])*
2151        #[derive(Clone, Debug)]
2152        pub struct $name {
2153            message: String,
2154            /// The underlying cause — `Throwable`'s `cause`, null by default.
2155            source: Option<Box<$crate::common::Error>>,
2156        }
2157
2158        impl $name {
2159            /// Create the error with the given message and no cause,
2160            /// mirroring the `(String message)` constructor.
2161            ///
2162            /// Keeps the plain name under CLAUDE.md §2, for consistency with
2163            /// `kafka_error_type!` — see the note on this macro about the
2164            /// constructors these classes deliberately do not model.
2165            /// (Deliberately not an intra-doc link: this doc comment expands
2166            /// into each declaring module, where that macro is not in scope.)
2167            pub fn new(message: impl Into<String>) -> Self {
2168                Self { message: message.into(), source: None }
2169            }
2170
2171            /// Create the error with the given message and an underlying cause,
2172            /// mirroring the `(String message, Throwable cause)` constructor.
2173            ///
2174            /// Suffixed with the one parameter beyond the `{message}`
2175            /// intersection (CLAUDE.md §2) — see [`new`](Self::new).
2176            pub fn with_source(message: impl Into<String>, source: $crate::common::Error) -> Self {
2177                Self { message: message.into(), source: Some(Box::new(source)) }
2178            }
2179
2180            /// The error message.
2181            pub fn message(&self) -> &str {
2182                &self.message
2183            }
2184
2185            /// The underlying cause, if any. Mirrors Java's `getCause()`.
2186            pub fn source(&self) -> Option<&$crate::common::Error> {
2187                self.source.as_deref()
2188            }
2189        }
2190
2191        impl $crate::common::error::ErrorSource for $name {
2192            fn source(&self) -> Option<&$crate::common::Error> {
2193                self.source.as_deref()
2194            }
2195        }
2196
2197        impl ::std::error::Error for $name {
2198            fn source(&self) -> Option<&(dyn ::std::error::Error + 'static)> {
2199                self.source
2200                    .as_deref()
2201                    .map(|e| e as &(dyn ::std::error::Error + 'static))
2202            }
2203        }
2204
2205        impl $crate::common::error::ErrorName for $name {
2206            fn name(&self) -> &'static str {
2207                stringify!($name)
2208            }
2209        }
2210
2211        // No protocol code: these are the generic `java.lang` / `java.util`
2212        // classes, raised only by this client and never reported by a broker, so
2213        // the trait default (`Errors::UnknownServerError`) is the right answer.
2214        impl $crate::common::error::ErrorCode for $name {}
2215
2216        impl $crate::common::error::ErrorMessage for $name {
2217            fn message(&self) -> &str {
2218                // Field access, not `self.message()`: that would resolve to the
2219                // inherent method above and is only accidentally equivalent.
2220                &self.message
2221            }
2222        }
2223
2224        impl ::std::fmt::Display for $name {
2225            fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
2226                write!(f, "{}: {}", stringify!($name), self.message)
2227            }
2228        }
2229    };
2230}
2231
2232pub(crate) use message_only_error;
2233
2234// ---------------------------------------------------------------------------
2235// Display — each payload renders itself, as each Java class has its own
2236// toString(). `Error`'s own Display just forwards (see `Error::as_display`).
2237// ---------------------------------------------------------------------------
2238
2239// `ErrorMessage` is not hand-written for any payload: the message-only types get
2240// it from the `message_only_error!` macro, the five that embed a [`KafkaError`]
2241// delegate to that field via `#[delegate(ErrorMessage, target = "kafka_error")]`,
2242// and [`KafkaError`] itself uses `target = "self"` over its inherent method.
2243
2244// ---------------------------------------------------------------------------
2245// ErrorName / ErrorHierarchy impls — each type's override list IS its Java
2246// `extends` chain
2247// ---------------------------------------------------------------------------
2248
2249// The fifteen payloads that are neither `kafka_error_type!` nor
2250// `message_only_error!` declarations: each adds subclass state, so it is
2251// hand-written in its own file. `ErrorName` is a crate-local trait, so the impls
2252// live here rather than in fifteen files — keeping the one place a reader can
2253// check that every payload answers, next to the trait itself. `KafkaError` is
2254// the sixteenth and answers next to its own struct, in `kafka_error.rs`.
2255macro_rules! error_name_impl {
2256    ($($name:ident),+ $(,)?) => {
2257        $(
2258            impl ErrorName for $name {
2259                fn name(&self) -> &'static str {
2260                    stringify!($name)
2261                }
2262            }
2263        )+
2264    };
2265}
2266
2267error_name_impl! {
2268    CorrelationIdMismatchError,
2269    DuplicateResourceError,
2270    GroupAuthorizationError,
2271    InvalidTopicError,
2272    InvalidReceiveError,
2273    RecordDeserializationError,
2274    ResourceNotFoundError,
2275    QuotaViolationError,
2276    ThrottlingQuotaExceededError,
2277    TopicAuthorizationError,
2278    ConsumerCommitFailedError,
2279    ConsumerLogTruncationError,
2280    ConsumerNoOffsetForPartitionError,
2281    ConsumerOffsetOutOfRangeError,
2282    ConsumerRetriableCommitFailedError,
2283    LocalCallbackError,
2284}
2285
2286// `IllegalArgumentException`, `IllegalStateException`,
2287// `UnsupportedOperationException`, `ConcurrentModificationException` and
2288// `java.util.concurrent.TimeoutException` are `java.lang` / `java.util` exceptions sitting BESIDE `KafkaException`, not
2289// below it. Every Kafka hierarchy predicate is false for them, so each overrides
2290// only its own class's predicate — the statement that they are outside the
2291// Kafka hierarchy.
2292impl ErrorHierarchy for LocalIllegalArgumentError {
2293    fn is_local_illegal_argument_error(&self) -> bool {
2294        true
2295    }
2296}
2297impl ErrorHierarchy for LocalIllegalStateError {
2298    fn is_local_illegal_state_error(&self) -> bool {
2299        true
2300    }
2301}
2302impl ErrorHierarchy for LocalConcurrentModificationError {
2303    fn is_local_concurrent_modification_error(&self) -> bool {
2304        true
2305    }
2306}
2307impl ErrorHierarchy for LocalTimeoutError {
2308    fn is_local_timeout_error(&self) -> bool {
2309        true
2310    }
2311}
2312impl ErrorHierarchy for LocalUnsupportedOperationError {
2313    fn is_local_unsupported_operation_error(&self) -> bool {
2314        true
2315    }
2316}
2317// Beside `KafkaException` like the five above: a foreign callback's error is
2318// not a Kafka error, so the client wraps it as Java wraps a foreign `Throwable`.
2319impl ErrorHierarchy for LocalCallbackError {
2320    fn is_local_callback_error(&self) -> bool {
2321        true
2322    }
2323}
2324
2325// ---------------------------------------------------------------------------
2326// Error — unified enum for polymorphic error handling
2327// ---------------------------------------------------------------------------
2328
2329/// Unified error type for polymorphic error handling — this crate's
2330/// top-level error, returned by every fallible API.
2331///
2332/// This enum wraps the error struct hierarchy so that any error can be
2333/// stored and returned through a single type. Most variants hold a specific
2334/// error struct that embeds [`KafkaError`] as its base;
2335/// [`KafkaError`](Self::KafkaError) holds a bare one, standing for Java's
2336/// `KafkaException` with no subclass.
2337///
2338/// It also carries the generic programming errors that Java keeps OUTSIDE
2339/// the `KafkaException` hierarchy ([`LocalIllegalArgument`](Self::LocalIllegalArgument),
2340/// [`LocalIllegalState`](Self::LocalIllegalState),
2341/// [`LocalConcurrentModification`](Self::LocalConcurrentModification)); flattening two
2342/// Java families into one enum is what makes
2343/// [`is_kafka_error`](Self::is_kafka_error) necessary.
2344///
2345/// **Classify by predicate, not by variant or code.** Java callers write
2346/// `e instanceof TopicAuthorizationException`; Rust callers write
2347/// `e.is_topic_authorization_error()`. Every variant has such a predicate,
2348/// and every intermediate Java class has one too. Prefer them to
2349/// `matches!(e, Error::TopicAuthorization(_))`. A predicate means "this class
2350/// or a subclass", like `instanceof`, so it still matches a subclass a later
2351/// Java release adds, whereas a variant match would miss it.
2352/// There is no public numeric
2353/// error code: the wire-level `Errors` enum lives in `common.protocol`, a
2354/// package Java marks "not a supported API", so the crate keeps it
2355/// `pub(crate)`. The C bindings expose the class as the
2356/// `kafka_common_Error_e` enum instead.
2357///
2358/// `message()` and `is_retriable_error()` are delegated to the inner
2359/// [`KafkaError`] base. `request_utils::RequestUtils::is_fatal_error` and
2360/// `is_transaction_abortable_error()`
2361/// live only here: `KafkaError` is Java's `KafkaException`, which has
2362/// neither, so these librdkafka-style predicates belong on this enum rather
2363/// than on the Java-shaped base.
2364///
2365/// This type is used in `Result` return types and `Option` storage where
2366/// any kind of Kafka error may occur.
2367#[derive(Clone, Debug, Delegate)]
2368#[delegate(ErrorHierarchy)]
2369#[delegate(ErrorMessage)]
2370#[delegate(ErrorCode)]
2371#[delegate(ErrorName)]
2372#[delegate(ErrorSource)]
2373#[delegate(Display)]
2374#[non_exhaustive]
2375// the crate's flat base error type (CLAUDE.md §12.3)
2376#[doc(alias = "rust-only")]
2377pub enum Error {
2378    // Payloads defined in this file: the bare `KafkaException` and the
2379    // generic `java.lang` / `java.util` runtime errors, which have no
2380    // package in the Kafka source to mirror.
2381    /// A plain Kafka error carrying only the base fields — Java's bare
2382    /// `KafkaException`, with no subclass-specific context.
2383    KafkaError(KafkaError),
2384    /// Illegal argument error — an invalid argument was provided to a method.
2385    ///
2386    /// Java's `IllegalArgumentException`.
2387    LocalIllegalArgument(LocalIllegalArgumentError),
2388    /// Illegal state error — a method was called in an invalid state.
2389    ///
2390    /// Java's `IllegalStateException`.
2391    LocalIllegalState(LocalIllegalStateError),
2392    /// Concurrent modification error — the consumer was accessed from more
2393    /// than one thread.
2394    ///
2395    /// Java's `java.util.ConcurrentModificationException`,
2396    /// thrown by `KafkaConsumer.acquire()` ("KafkaConsumer is not safe for
2397    /// multi-threaded access"). Like `LocalIllegalState`, it is a plain
2398    /// `RuntimeException` — neither an `ApiException` nor a `KafkaException`
2399    /// — so it is never retriable and never fatal.
2400    LocalConcurrentModification(LocalConcurrentModificationError),
2401    /// A wait on a future timed out.
2402    ///
2403    /// Java's `java.util.concurrent.TimeoutException` raised by
2404    /// `Future.get(timeout, unit)`. Distinct from
2405    /// [`Timeout`](Self::Timeout), which is
2406    /// `org.apache.kafka.common.errors.TimeoutException` — a
2407    /// `RetriableException`. This one sits beside `KafkaException`, so it is
2408    /// never retriable, never an api error and carries no wire code.
2409    LocalTimeout(LocalTimeoutError),
2410    /// Unsupported operation error — the requested operation is not supported.
2411    ///
2412    /// Java's `java.lang.UnsupportedOperationException`, thrown
2413    /// where Java leaves an operation unimplemented (`MockAdminClient`'s "Not
2414    /// implemented yet" methods, `MockConsumer.offsetsForTimes`) or rejects it
2415    /// (`Compression.decompressionOutputSize`). Like `LocalIllegalState` it is a
2416    /// plain `RuntimeException` — neither an `ApiException` nor a
2417    /// `KafkaException` — so it is never retriable and never fatal. Distinct
2418    /// from [`UnsupportedVersion`](Self::UnsupportedVersion), the wire-level
2419    /// `ApiException` for a broker lacking an API version.
2420    LocalUnsupportedOperation(LocalUnsupportedOperationError),
2421    /// An error raised by a callback written in another language.
2422    ///
2423    /// No Java class: it stands in for the foreign error, which cannot cross
2424    /// the FFI boundary, and carries an opaque pointer the binding uses to find
2425    /// the original again. Outside the Kafka hierarchy, like
2426    /// [`LocalIllegalState`](Self::LocalIllegalState), so the client wraps it
2427    /// as Java wraps a listener's foreign `Throwable`.
2428    LocalCallback(LocalCallbackError),
2429
2430    // One variant per Java exception class, each carrying the struct that
2431    // declares its own `extends` chain. Delegation does the rest.
2432    /// See [`ApiError`](crate::common::errors::ApiError).
2433    Api(ApiError),
2434    /// See [`AuthenticationError`](crate::common::errors::AuthenticationError).
2435    Authentication(AuthenticationError),
2436    /// See [`AuthorizationError`](crate::common::errors::AuthorizationError).
2437    Authorization(AuthorizationError),
2438    /// See [`AuthorizerNotReadyError`](crate::common::errors::AuthorizerNotReadyError).
2439    AuthorizerNotReady(AuthorizerNotReadyError),
2440    /// See [`BootstrapResolutionError`](crate::common::errors::BootstrapResolutionError).
2441    BootstrapResolution(BootstrapResolutionError),
2442    /// See [`BrokerIdNotRegisteredError`](crate::common::errors::BrokerIdNotRegisteredError).
2443    BrokerIdNotRegistered(BrokerIdNotRegisteredError),
2444    /// See [`BrokerNotAvailableError`](crate::common::errors::BrokerNotAvailableError).
2445    BrokerNotAvailable(BrokerNotAvailableError),
2446    /// See [`ProducerBufferExhaustedError`](crate::producer::ProducerBufferExhaustedError).
2447    ProducerBufferExhausted(ProducerBufferExhaustedError),
2448    /// See [`ClusterAuthorizationError`](crate::common::errors::ClusterAuthorizationError).
2449    ClusterAuthorization(ClusterAuthorizationError),
2450    /// See [`ConcurrentTransactionsError`](crate::common::errors::ConcurrentTransactionsError).
2451    ConcurrentTransactions(ConcurrentTransactionsError),
2452    /// See [`ControllerIdNotRegisteredError`](crate::common::errors::ControllerIdNotRegisteredError).
2453    ControllerIdNotRegistered(ControllerIdNotRegisteredError),
2454    /// See [`ControllerMovedError`](crate::common::errors::ControllerMovedError).
2455    ControllerMoved(ControllerMovedError),
2456    /// See [`CoordinatorLoadInProgressError`](crate::common::errors::CoordinatorLoadInProgressError).
2457    CoordinatorLoadInProgress(CoordinatorLoadInProgressError),
2458    /// See [`CoordinatorNotAvailableError`](crate::common::errors::CoordinatorNotAvailableError).
2459    CoordinatorNotAvailable(CoordinatorNotAvailableError),
2460    /// See `CorrelationIdMismatchError`.
2461    ///
2462    /// Lives in `common.requests`, not `common.errors`, and extends
2463    /// `IllegalStateException` rather than `KafkaException` — so like
2464    /// [`LocalIllegalState`](Self::LocalIllegalState) it answers `false` to every
2465    /// predicate.
2466    CorrelationIdMismatch(CorrelationIdMismatchError),
2467    /// See [`CorruptRecordError`](crate::common::errors::CorruptRecordError).
2468    CorruptRecord(CorruptRecordError),
2469    /// See [`DelegationTokenAuthorizationError`](crate::common::errors::DelegationTokenAuthorizationError).
2470    DelegationTokenAuthorization(DelegationTokenAuthorizationError),
2471    /// See [`DelegationTokenDisabledError`](crate::common::errors::DelegationTokenDisabledError).
2472    DelegationTokenDisabled(DelegationTokenDisabledError),
2473    /// See [`DelegationTokenExpiredError`](crate::common::errors::DelegationTokenExpiredError).
2474    DelegationTokenExpired(DelegationTokenExpiredError),
2475    /// See [`DelegationTokenNotFoundError`](crate::common::errors::DelegationTokenNotFoundError).
2476    DelegationTokenNotFound(DelegationTokenNotFoundError),
2477    /// See [`DelegationTokenOwnerMismatchError`](crate::common::errors::DelegationTokenOwnerMismatchError).
2478    DelegationTokenOwnerMismatch(DelegationTokenOwnerMismatchError),
2479    /// See [`DisconnectError`](crate::common::errors::DisconnectError).
2480    Disconnect(DisconnectError),
2481    /// See [`DuplicateBrokerRegistrationError`](crate::common::errors::DuplicateBrokerRegistrationError).
2482    DuplicateBrokerRegistration(DuplicateBrokerRegistrationError),
2483    /// See [`DuplicateResourceError`](crate::common::errors::DuplicateResourceError).
2484    DuplicateResource(DuplicateResourceError),
2485    /// See [`DuplicateSequenceError`](crate::common::errors::DuplicateSequenceError).
2486    DuplicateSequence(DuplicateSequenceError),
2487    /// See [`DuplicateVoterError`](crate::common::errors::DuplicateVoterError).
2488    DuplicateVoter(DuplicateVoterError),
2489    /// See [`ElectionNotNeededError`](crate::common::errors::ElectionNotNeededError).
2490    ElectionNotNeeded(ElectionNotNeededError),
2491    /// See [`EligibleLeadersNotAvailableError`](crate::common::errors::EligibleLeadersNotAvailableError).
2492    EligibleLeadersNotAvailable(EligibleLeadersNotAvailableError),
2493    /// See [`FeatureUpdateFailedError`](crate::common::errors::FeatureUpdateFailedError).
2494    FeatureUpdateFailed(FeatureUpdateFailedError),
2495    /// See [`FencedInstanceIdError`](crate::common::errors::FencedInstanceIdError).
2496    FencedInstanceId(FencedInstanceIdError),
2497    /// See [`FencedLeaderEpochError`](crate::common::errors::FencedLeaderEpochError).
2498    FencedLeaderEpoch(FencedLeaderEpochError),
2499    /// See [`FencedMemberEpochError`](crate::common::errors::FencedMemberEpochError).
2500    FencedMemberEpoch(FencedMemberEpochError),
2501    /// See [`FencedStateEpochError`](crate::common::errors::FencedStateEpochError).
2502    FencedStateEpoch(FencedStateEpochError),
2503    /// See [`FetchSessionIdNotFoundError`](crate::common::errors::FetchSessionIdNotFoundError).
2504    FetchSessionIdNotFound(FetchSessionIdNotFoundError),
2505    /// See [`FetchSessionTopicIdError`](crate::common::errors::FetchSessionTopicIdError).
2506    FetchSessionTopicId(FetchSessionTopicIdError),
2507    /// See [`GroupAuthorizationError`](crate::common::errors::GroupAuthorizationError).
2508    GroupAuthorization(GroupAuthorizationError),
2509    /// See [`GroupDeletionFailedError`](crate::common::errors::GroupDeletionFailedError).
2510    GroupDeletionFailed(GroupDeletionFailedError),
2511    /// See [`GroupIdNotFoundError`](crate::common::errors::GroupIdNotFoundError).
2512    GroupIdNotFound(GroupIdNotFoundError),
2513    /// See [`GroupMaxSizeReachedError`](crate::common::errors::GroupMaxSizeReachedError).
2514    GroupMaxSizeReached(GroupMaxSizeReachedError),
2515    /// See [`GroupNotEmptyError`](crate::common::errors::GroupNotEmptyError).
2516    GroupNotEmpty(GroupNotEmptyError),
2517    /// See [`GroupSubscribedToTopicError`](crate::common::errors::GroupSubscribedToTopicError).
2518    GroupSubscribedToTopic(GroupSubscribedToTopicError),
2519    /// See [`IllegalGenerationError`](crate::common::errors::IllegalGenerationError).
2520    IllegalGeneration(IllegalGenerationError),
2521    /// See [`IllegalSaslStateError`](crate::common::errors::IllegalSaslStateError).
2522    IllegalSaslState(IllegalSaslStateError),
2523    /// See [`InconsistentClusterIdError`](crate::common::errors::InconsistentClusterIdError).
2524    InconsistentClusterId(InconsistentClusterIdError),
2525    /// See [`InconsistentGroupProtocolError`](crate::common::errors::InconsistentGroupProtocolError).
2526    InconsistentGroupProtocol(InconsistentGroupProtocolError),
2527    /// See [`InconsistentTopicIdError`](crate::common::errors::InconsistentTopicIdError).
2528    InconsistentTopicId(InconsistentTopicIdError),
2529    /// See [`InconsistentVoterSetError`](crate::common::errors::InconsistentVoterSetError).
2530    InconsistentVoterSet(InconsistentVoterSetError),
2531    /// See [`IneligibleReplicaError`](crate::common::errors::IneligibleReplicaError).
2532    IneligibleReplica(IneligibleReplicaError),
2533    /// See [`InterruptError`](crate::common::errors::InterruptError).
2534    Interrupt(InterruptError),
2535    /// See [`InvalidCommitOffsetSizeError`](crate::common::errors::InvalidCommitOffsetSizeError).
2536    InvalidCommitOffsetSize(InvalidCommitOffsetSizeError),
2537    /// See [`InvalidConfigurationError`](crate::common::errors::InvalidConfigurationError).
2538    InvalidConfiguration(InvalidConfigurationError),
2539    /// See [`InvalidFetchSessionEpochError`](crate::common::errors::InvalidFetchSessionEpochError).
2540    InvalidFetchSessionEpoch(InvalidFetchSessionEpochError),
2541    /// See [`InvalidFetchSizeError`](crate::common::errors::InvalidFetchSizeError).
2542    InvalidFetchSize(InvalidFetchSizeError),
2543    /// See [`InvalidGroupIdError`](crate::common::errors::InvalidGroupIdError).
2544    InvalidGroupId(InvalidGroupIdError),
2545    /// See [`InvalidOffsetError`](crate::common::errors::InvalidOffsetError).
2546    InvalidOffset(InvalidOffsetError),
2547    /// See [`InvalidPartitionsError`](crate::common::errors::InvalidPartitionsError).
2548    InvalidPartitions(InvalidPartitionsError),
2549    /// See [`InvalidPidMappingError`](crate::common::errors::InvalidPidMappingError).
2550    InvalidPidMapping(InvalidPidMappingError),
2551    /// See [`InvalidPrincipalTypeError`](crate::common::errors::InvalidPrincipalTypeError).
2552    InvalidPrincipalType(InvalidPrincipalTypeError),
2553    /// See [`InvalidProducerEpochError`](crate::common::errors::InvalidProducerEpochError).
2554    InvalidProducerEpoch(InvalidProducerEpochError),
2555    /// See [`InvalidRecordError`](crate::common::InvalidRecordError).
2556    InvalidRecord(InvalidRecordError),
2557    /// See [`InvalidRecordStateError`](crate::common::errors::InvalidRecordStateError).
2558    InvalidRecordState(InvalidRecordStateError),
2559    /// See [`InvalidRegistrationError`](crate::common::errors::InvalidRegistrationError).
2560    InvalidRegistration(InvalidRegistrationError),
2561    /// See [`InvalidRegularExpression`](crate::common::errors::InvalidRegularExpression).
2562    InvalidRegularExpression(InvalidRegularExpression),
2563    /// See [`InvalidReplicaAssignmentError`](crate::common::errors::InvalidReplicaAssignmentError).
2564    InvalidReplicaAssignment(InvalidReplicaAssignmentError),
2565    /// See [`InvalidReplicationFactorError`](crate::common::errors::InvalidReplicationFactorError).
2566    InvalidReplicationFactor(InvalidReplicationFactorError),
2567    /// See [`InvalidRequestError`](crate::common::errors::InvalidRequestError).
2568    InvalidRequest(InvalidRequestError),
2569    /// See [`InvalidRequiredAcksError`](crate::common::errors::InvalidRequiredAcksError).
2570    InvalidRequiredAcks(InvalidRequiredAcksError),
2571    /// See [`InvalidSessionTimeoutError`](crate::common::errors::InvalidSessionTimeoutError).
2572    InvalidSessionTimeout(InvalidSessionTimeoutError),
2573    /// See [`InvalidShareSessionEpochError`](crate::common::errors::InvalidShareSessionEpochError).
2574    InvalidShareSessionEpoch(InvalidShareSessionEpochError),
2575    /// See [`InvalidTimestampError`](crate::common::errors::InvalidTimestampError).
2576    InvalidTimestamp(InvalidTimestampError),
2577    /// See [`InvalidTopicError`](crate::common::errors::InvalidTopicError).
2578    InvalidTopic(InvalidTopicError),
2579    /// See [`InvalidTxnStateError`](crate::common::errors::InvalidTxnStateError).
2580    InvalidTxnState(InvalidTxnStateError),
2581    /// See [`InvalidTxnTimeoutError`](crate::common::errors::InvalidTxnTimeoutError).
2582    InvalidTxnTimeout(InvalidTxnTimeoutError),
2583    /// See [`InvalidUpdateVersionError`](crate::common::errors::InvalidUpdateVersionError).
2584    InvalidUpdateVersion(InvalidUpdateVersionError),
2585    /// See [`InvalidVoterKeyError`](crate::common::errors::InvalidVoterKeyError).
2586    InvalidVoterKey(InvalidVoterKeyError),
2587    /// See [`KafkaStorageError`](crate::common::errors::KafkaStorageError).
2588    KafkaStorage(KafkaStorageError),
2589    /// See [`LeaderNotAvailableError`](crate::common::errors::LeaderNotAvailableError).
2590    LeaderNotAvailable(LeaderNotAvailableError),
2591    /// See [`ListenerNotFoundError`](crate::common::errors::ListenerNotFoundError).
2592    ListenerNotFound(ListenerNotFoundError),
2593    /// See [`LogDirNotFoundError`](crate::common::errors::LogDirNotFoundError).
2594    LogDirNotFound(LogDirNotFoundError),
2595    /// See [`MemberIdRequiredError`](crate::common::errors::MemberIdRequiredError).
2596    MemberIdRequired(MemberIdRequiredError),
2597    /// See [`MismatchedEndpointTypeError`](crate::common::errors::MismatchedEndpointTypeError).
2598    MismatchedEndpointType(MismatchedEndpointTypeError),
2599    /// See [`NetworkError`](crate::common::errors::NetworkError).
2600    Network(NetworkError),
2601    /// See [`NewLeaderElectedError`](crate::common::errors::NewLeaderElectedError).
2602    NewLeaderElected(NewLeaderElectedError),
2603    /// See [`NoReassignmentInProgressError`](crate::common::errors::NoReassignmentInProgressError).
2604    NoReassignmentInProgress(NoReassignmentInProgressError),
2605    /// See [`NotControllerError`](crate::common::errors::NotControllerError).
2606    NotController(NotControllerError),
2607    /// See [`NotCoordinatorError`](crate::common::errors::NotCoordinatorError).
2608    NotCoordinator(NotCoordinatorError),
2609    /// See [`NotEnoughReplicasError`](crate::common::errors::NotEnoughReplicasError).
2610    NotEnoughReplicas(NotEnoughReplicasError),
2611    /// See [`NotEnoughReplicasAfterAppendError`](crate::common::errors::NotEnoughReplicasAfterAppendError).
2612    NotEnoughReplicasAfterAppend(NotEnoughReplicasAfterAppendError),
2613    /// See [`NotLeaderOrFollowerError`](crate::common::errors::NotLeaderOrFollowerError).
2614    NotLeaderOrFollower(NotLeaderOrFollowerError),
2615    /// See [`OffsetMetadataTooLarge`](crate::common::errors::OffsetMetadataTooLarge).
2616    OffsetMetadataTooLarge(OffsetMetadataTooLarge),
2617    /// See [`OffsetMovedToTieredStorageError`](crate::common::errors::OffsetMovedToTieredStorageError).
2618    OffsetMovedToTieredStorage(OffsetMovedToTieredStorageError),
2619    /// See [`OffsetNotAvailableError`](crate::common::errors::OffsetNotAvailableError).
2620    OffsetNotAvailable(OffsetNotAvailableError),
2621    /// See [`OffsetOutOfRangeError`](crate::common::errors::OffsetOutOfRangeError).
2622    OffsetOutOfRange(OffsetOutOfRangeError),
2623    /// See [`OperationNotAttemptedError`](crate::common::errors::OperationNotAttemptedError).
2624    OperationNotAttempted(OperationNotAttemptedError),
2625    /// See [`OutOfOrderSequenceError`](crate::common::errors::OutOfOrderSequenceError).
2626    OutOfOrderSequence(OutOfOrderSequenceError),
2627    /// See [`PolicyViolationError`](crate::common::errors::PolicyViolationError).
2628    PolicyViolation(PolicyViolationError),
2629    /// See [`PositionOutOfRangeError`](crate::common::errors::PositionOutOfRangeError).
2630    PositionOutOfRange(PositionOutOfRangeError),
2631    /// See [`PreferredLeaderNotAvailableError`](crate::common::errors::PreferredLeaderNotAvailableError).
2632    PreferredLeaderNotAvailable(PreferredLeaderNotAvailableError),
2633    /// See [`PrincipalDeserializationError`](crate::common::errors::PrincipalDeserializationError).
2634    PrincipalDeserialization(PrincipalDeserializationError),
2635    /// See [`ProducerFencedError`](crate::common::errors::ProducerFencedError).
2636    ProducerFenced(ProducerFencedError),
2637    /// See [`QuotaViolationError`](crate::common::metrics::QuotaViolationError).
2638    ///
2639    /// Boxed for the same reason as [`RecordDeserialization`](Self::RecordDeserialization):
2640    /// it carries a whole [`MetricName`](crate::common::MetricName) (three
2641    /// `String`s and a `BTreeMap`), which unboxed makes it the largest payload in
2642    /// the enum at 120 bytes and pushes `Error` — and with it every
2643    /// `Result<_, Error>` in the crate — past clippy's 128-byte
2644    /// `result_large_err` threshold.
2645    QuotaViolation(Box<QuotaViolationError>),
2646    /// See [`ReassignmentInProgressError`](crate::common::errors::ReassignmentInProgressError).
2647    ReassignmentInProgress(ReassignmentInProgressError),
2648    /// See [`RebalanceInProgressError`](crate::common::errors::RebalanceInProgressError).
2649    RebalanceInProgress(RebalanceInProgressError),
2650    /// See [`RebootstrapRequiredError`](crate::common::errors::RebootstrapRequiredError).
2651    RebootstrapRequired(RebootstrapRequiredError),
2652    /// See [`RecordBatchTooLargeError`](crate::common::errors::RecordBatchTooLargeError).
2653    RecordBatchTooLarge(RecordBatchTooLargeError),
2654    /// See [`RecordDeserializationError`](crate::common::errors::RecordDeserializationError).
2655    ///
2656    /// Boxed: it carries the full record context (partition, offsets, key/value
2657    /// buffers, headers), which unboxed pushes `Error` — and every
2658    /// `Result<_, Error>` — past clippy's 128-byte `result_large_err` threshold.
2659    RecordDeserialization(Box<RecordDeserializationError>),
2660    /// See [`RecordTooLargeError`](crate::common::errors::RecordTooLargeError).
2661    RecordTooLarge(RecordTooLargeError),
2662    /// See `InvalidReceiveError`.
2663    InvalidReceive(InvalidReceiveError),
2664    /// See [`ConfigError`](crate::common::config::ConfigError).
2665    Config(ConfigError),
2666    /// See [`ConsumerRetriableCommitFailedError`](crate::consumer::ConsumerRetriableCommitFailedError).
2667    ConsumerRetriableCommitFailed(ConsumerRetriableCommitFailedError),
2668    /// See [`ConsumerCommitFailedError`](crate::consumer::ConsumerCommitFailedError).
2669    ConsumerCommitFailed(ConsumerCommitFailedError),
2670    /// See [`ConsumerNoOffsetForPartitionError`](crate::consumer::ConsumerNoOffsetForPartitionError).
2671    ConsumerNoOffsetForPartition(ConsumerNoOffsetForPartitionError),
2672    /// See [`ConsumerOffsetOutOfRangeError`](crate::consumer::ConsumerOffsetOutOfRangeError).
2673    ConsumerOffsetOutOfRange(ConsumerOffsetOutOfRangeError),
2674    /// See [`ConsumerLogTruncationError`](crate::consumer::ConsumerLogTruncationError).
2675    ///
2676    /// Boxed: it carries two maps, and unboxed it made `Error` — and therefore
2677    /// every `Result<_, Error>` in the crate — exceed 128 bytes.
2678    ConsumerLogTruncation(Box<ConsumerLogTruncationError>),
2679    /// See [`ReplicaNotAvailableError`](crate::common::errors::ReplicaNotAvailableError).
2680    ReplicaNotAvailable(ReplicaNotAvailableError),
2681    /// See [`ResourceNotFoundError`](crate::common::errors::ResourceNotFoundError).
2682    ResourceNotFound(ResourceNotFoundError),
2683    /// See [`SaslAuthenticationError`](crate::common::errors::SaslAuthenticationError).
2684    SaslAuthentication(SaslAuthenticationError),
2685    /// See `SchemaError`.
2686    ///
2687    /// Lives in `common.protocol.types`, not `common.errors`.
2688    Schema(SchemaError),
2689    /// See [`SecurityDisabledError`](crate::common::errors::SecurityDisabledError).
2690    SecurityDisabled(SecurityDisabledError),
2691    /// See [`SerializationError`](crate::common::errors::SerializationError).
2692    Serialization(SerializationError),
2693    /// See [`ShareSessionLimitReachedError`](crate::common::errors::ShareSessionLimitReachedError).
2694    ShareSessionLimitReached(ShareSessionLimitReachedError),
2695    /// See [`ShareSessionNotFoundError`](crate::common::errors::ShareSessionNotFoundError).
2696    ShareSessionNotFound(ShareSessionNotFoundError),
2697    /// See [`SnapshotNotFoundError`](crate::common::errors::SnapshotNotFoundError).
2698    SnapshotNotFound(SnapshotNotFoundError),
2699    /// See [`SslAuthenticationError`](crate::common::errors::SslAuthenticationError).
2700    SslAuthentication(SslAuthenticationError),
2701    /// See [`StaleBrokerEpochError`](crate::common::errors::StaleBrokerEpochError).
2702    StaleBrokerEpoch(StaleBrokerEpochError),
2703    /// See [`StaleMemberEpochError`](crate::common::errors::StaleMemberEpochError).
2704    StaleMemberEpoch(StaleMemberEpochError),
2705    /// See [`StreamsInvalidTopologyError`](crate::common::errors::StreamsInvalidTopologyError).
2706    StreamsInvalidTopology(StreamsInvalidTopologyError),
2707    /// See [`StreamsInvalidTopologyEpochError`](crate::common::errors::StreamsInvalidTopologyEpochError).
2708    StreamsInvalidTopologyEpoch(StreamsInvalidTopologyEpochError),
2709    /// See [`StreamsTopologyDescriptionUpdateFailedError`](crate::common::errors::StreamsTopologyDescriptionUpdateFailedError).
2710    StreamsTopologyDescriptionUpdateFailed(StreamsTopologyDescriptionUpdateFailedError),
2711    /// See [`StreamsTopologyFencedError`](crate::common::errors::StreamsTopologyFencedError).
2712    StreamsTopologyFenced(StreamsTopologyFencedError),
2713    /// See [`TelemetryTooLargeError`](crate::common::errors::TelemetryTooLargeError).
2714    TelemetryTooLarge(TelemetryTooLargeError),
2715    /// See [`ThrottlingQuotaExceededError`](crate::common::errors::ThrottlingQuotaExceededError).
2716    ThrottlingQuotaExceeded(ThrottlingQuotaExceededError),
2717    /// See [`TimeoutError`](crate::common::errors::TimeoutError).
2718    Timeout(TimeoutError),
2719    /// See [`TopicAuthorizationError`](crate::common::errors::TopicAuthorizationError).
2720    TopicAuthorization(TopicAuthorizationError),
2721    /// See [`TopicDeletionDisabledError`](crate::common::errors::TopicDeletionDisabledError).
2722    TopicDeletionDisabled(TopicDeletionDisabledError),
2723    /// See [`TopicExistsError`](crate::common::errors::TopicExistsError).
2724    TopicExists(TopicExistsError),
2725    /// See [`TransactionAbortableError`](crate::common::errors::TransactionAbortableError).
2726    TransactionAbortable(TransactionAbortableError),
2727    /// See [`TransactionAbortedError`](crate::common::errors::TransactionAbortedError).
2728    TransactionAborted(TransactionAbortedError),
2729    /// See [`TransactionCoordinatorFencedError`](crate::common::errors::TransactionCoordinatorFencedError).
2730    TransactionCoordinatorFenced(TransactionCoordinatorFencedError),
2731    /// See [`TransactionalIdAuthorizationError`](crate::common::errors::TransactionalIdAuthorizationError).
2732    TransactionalIdAuthorization(TransactionalIdAuthorizationError),
2733    /// See [`TransactionalIdNotFoundError`](crate::common::errors::TransactionalIdNotFoundError).
2734    TransactionalIdNotFound(TransactionalIdNotFoundError),
2735    /// See [`UnacceptableCredentialError`](crate::common::errors::UnacceptableCredentialError).
2736    UnacceptableCredential(UnacceptableCredentialError),
2737    /// See [`UnknownControllerIdError`](crate::common::errors::UnknownControllerIdError).
2738    UnknownControllerId(UnknownControllerIdError),
2739    /// See [`UnknownLeaderEpochError`](crate::common::errors::UnknownLeaderEpochError).
2740    UnknownLeaderEpoch(UnknownLeaderEpochError),
2741    /// See [`UnknownMemberIdError`](crate::common::errors::UnknownMemberIdError).
2742    UnknownMemberId(UnknownMemberIdError),
2743    /// See [`UnknownProducerIdError`](crate::common::errors::UnknownProducerIdError).
2744    UnknownProducerId(UnknownProducerIdError),
2745    /// See [`UnknownServerError`](crate::common::errors::UnknownServerError).
2746    UnknownServer(UnknownServerError),
2747    /// See [`UnknownSubscriptionIdError`](crate::common::errors::UnknownSubscriptionIdError).
2748    UnknownSubscriptionId(UnknownSubscriptionIdError),
2749    /// See [`UnknownTopicIdError`](crate::common::errors::UnknownTopicIdError).
2750    UnknownTopicId(UnknownTopicIdError),
2751    /// See [`UnknownTopicOrPartitionError`](crate::common::errors::UnknownTopicOrPartitionError).
2752    UnknownTopicOrPartition(UnknownTopicOrPartitionError),
2753    /// See [`UnreleasedInstanceIdError`](crate::common::errors::UnreleasedInstanceIdError).
2754    UnreleasedInstanceId(UnreleasedInstanceIdError),
2755    /// See [`UnstableOffsetCommitError`](crate::common::errors::UnstableOffsetCommitError).
2756    UnstableOffsetCommit(UnstableOffsetCommitError),
2757    /// See [`UnsupportedAssignorError`](crate::common::errors::UnsupportedAssignorError).
2758    UnsupportedAssignor(UnsupportedAssignorError),
2759    /// See [`UnsupportedByAuthenticationError`](crate::common::errors::UnsupportedByAuthenticationError).
2760    UnsupportedByAuthentication(UnsupportedByAuthenticationError),
2761    /// See [`UnsupportedCompressionTypeError`](crate::common::errors::UnsupportedCompressionTypeError).
2762    UnsupportedCompressionType(UnsupportedCompressionTypeError),
2763    /// See [`UnsupportedEndpointTypeError`](crate::common::errors::UnsupportedEndpointTypeError).
2764    UnsupportedEndpointType(UnsupportedEndpointTypeError),
2765    /// See [`UnsupportedForMessageFormatError`](crate::common::errors::UnsupportedForMessageFormatError).
2766    UnsupportedForMessageFormat(UnsupportedForMessageFormatError),
2767    /// See [`UnsupportedSaslMechanismError`](crate::common::errors::UnsupportedSaslMechanismError).
2768    UnsupportedSaslMechanism(UnsupportedSaslMechanismError),
2769    /// See [`UnsupportedVersionError`](crate::common::errors::UnsupportedVersionError).
2770    UnsupportedVersion(UnsupportedVersionError),
2771    /// See [`VoterNotFoundError`](crate::common::errors::VoterNotFoundError).
2772    VoterNotFound(VoterNotFoundError),
2773    /// See [`WakeupError`](crate::common::errors::WakeupError).
2774    Wakeup(WakeupError),
2775}
2776
2777impl Error {
2778    // -- Convenience constructors ------------------------------------------
2779
2780    /// Create a bare Kafka error from an error code.
2781    pub(crate) fn new(error: Errors) -> Self {
2782        // Java's `Errors.exception()`: the code names a class, and that class —
2783        // not this enum — knows its ancestry. The fallback covers `Errors::None`,
2784        // which Java maps to a null exception.
2785        error.error().unwrap_or_else(|| Self::KafkaError(KafkaError::new(error)))
2786    }
2787
2788    /// Create a bare Kafka error with a custom message.
2789    pub(crate) fn with_message(error: Errors, message: impl Into<String>) -> Self {
2790        // Java's `Errors.exception(String)`.
2791        let message = message.into();
2792        error
2793            .error_with_message(&message)
2794            .unwrap_or_else(|| Self::KafkaError(KafkaError::with_message(error, message)))
2795    }
2796
2797    /// Creates a bare Kafka error with no message, Java's no-arg `new KafkaException()`.
2798    ///
2799    /// The four `kafka*` constructors translate `KafkaException`'s four constructors.
2800    /// Their parameter-name intersection is empty and the no-arg form matches it, so
2801    /// this one keeps the plain name and the others are suffixed with their parameters.
2802    ///
2803    /// This is deliberately NOT `new` with `Errors::UnknownServerError`: that
2804    /// constructor resolves the code to the class Java associates with it and yields
2805    /// [`UnknownServer`](Self::UnknownServer), an `ApiException`. Java's bare
2806    /// `KafkaException` is a *sibling* of `ApiException`, not a subclass, so it belongs
2807    /// in the [`KafkaError`](Self::KafkaError) variant. The difference is observable:
2808    /// [`is_api_error`](Self::is_api_error) answers `false` here and `true` there, and
2809    /// callers such as `KafkaProducer.doSend` dispatch on exactly that
2810    /// (`catch (ApiException e)` returns a failed future, `catch (KafkaException e)`
2811    /// rethrows).
2812    ///
2813    /// The wire code stays `Errors::UnknownServerError` because a client-constructed
2814    /// `KafkaException` has no protocol code of its own.
2815    ///
2816    /// Java's no-arg form leaves the message null; Rust reports the code's default
2817    /// message instead, since [`KafkaError`] stores the code rather than deriving it
2818    /// from a subclass and always has one to fall back on.
2819    pub fn kafka() -> Self {
2820        Self::KafkaError(KafkaError::new(Errors::UnknownServerError))
2821    }
2822
2823    /// Creates a bare Kafka error, Java's `new KafkaException(String message)`.
2824    ///
2825    /// See [`kafka`](Self::kafka) for why this does not go through `with_message`.
2826    ///
2827    /// # Arguments
2828    ///
2829    /// - `message` - the error message
2830    pub fn kafka_message(message: impl Into<String>) -> Self {
2831        Self::KafkaError(KafkaError::with_message(Errors::UnknownServerError, message))
2832    }
2833
2834    /// Creates a bare Kafka error carrying only the error that caused it, Java's
2835    /// `new KafkaException(Throwable cause)`.
2836    ///
2837    /// See [`kafka`](Self::kafka) for why this does not go through `with_message`.
2838    ///
2839    /// # Arguments
2840    ///
2841    /// - `source` - the error that caused this one, returned by [`source`](Self::source)
2842    pub fn kafka_source(source: Error) -> Self {
2843        Self::KafkaError(KafkaError::with_source(Errors::UnknownServerError, source))
2844    }
2845
2846    /// Creates a bare Kafka error carrying the error that caused it, Java's
2847    /// `new KafkaException(String message, Throwable cause)`.
2848    ///
2849    /// See [`kafka`](Self::kafka) for why this does not go through `with_message`.
2850    ///
2851    /// # Arguments
2852    ///
2853    /// - `message` - the error message
2854    /// - `source` - the error that caused this one, returned by [`source`](Self::source)
2855    pub fn kafka_message_source(message: impl Into<String>, source: Error) -> Self {
2856        Self::KafkaError(KafkaError::with_message_source(Errors::UnknownServerError, message, source))
2857    }
2858
2859    /// Creates a topic authorization error, Java's
2860    /// `new TopicAuthorizationException(unauthorizedTopics)`.
2861    ///
2862    /// The pair intersects on `{unauthorizedTopics}`, which is exactly this overload,
2863    /// so it keeps the plain name.
2864    ///
2865    /// # Arguments
2866    ///
2867    /// - `topics` - the topics the client is not authorized to access
2868    pub fn topic_authorization(topics: HashSet<String>) -> Self {
2869        Self::TopicAuthorization(TopicAuthorizationError::new(topics))
2870    }
2871
2872    /// Creates a topic authorization error carrying a custom message, Java's
2873    /// `new TopicAuthorizationException(message, unauthorizedTopics)`.
2874    ///
2875    /// # Arguments
2876    ///
2877    /// - `topics` - the topics the client is not authorized to access
2878    /// - `message` - the error message
2879    pub fn topic_authorization_message(topics: HashSet<String>, message: impl Into<String>) -> Self {
2880        Self::TopicAuthorization(TopicAuthorizationError::with_message(topics, message))
2881    }
2882
2883    /// Creates an invalid topic error, Java's `new InvalidTopicException(invalidTopics)`.
2884    ///
2885    /// The pair intersects on `{invalidTopics}`, which is exactly this overload, so it
2886    /// keeps the plain name.
2887    ///
2888    /// # Arguments
2889    ///
2890    /// - `topics` - the invalid topic names
2891    pub fn invalid_topics(topics: HashSet<String>) -> Self {
2892        Self::InvalidTopic(InvalidTopicError::new(topics))
2893    }
2894
2895    /// Creates an invalid topic error carrying a custom message, Java's
2896    /// `new InvalidTopicException(message, invalidTopics)`, and the
2897    /// `new InvalidTopicException(String message)` form when `topics` is empty.
2898    ///
2899    /// # Arguments
2900    ///
2901    /// - `topics` - the invalid topic names, possibly empty
2902    /// - `message` - the error message
2903    pub fn invalid_topics_message(topics: HashSet<String>, message: impl Into<String>) -> Self {
2904        Self::InvalidTopic(InvalidTopicError::with_message(topics, message))
2905    }
2906
2907    // The two `group_authorization*` factories below are NOT an overload group:
2908    // the first translates Java's `static forGroupId(String)` and the second the
2909    // `(String message, String groupId)` constructor. Distinct Java members, so
2910    // CLAUDE.md §2's suffixing does not apply and neither name changes.
2911
2912    /// Creates a group authorization error for a group ID, formatting the group into
2913    /// the message, Java's `GroupAuthorizationException.forGroupId(groupId)`.
2914    ///
2915    /// # Arguments
2916    ///
2917    /// - `group_id` - the group the client is not authorized to access
2918    pub fn group_authorization(group_id: impl Into<String>) -> Self {
2919        Self::GroupAuthorization(GroupAuthorizationError::for_group_id(group_id))
2920    }
2921
2922    /// Creates a group authorization error carrying a custom message, Java's
2923    /// `new GroupAuthorizationException(message, groupId)`.
2924    ///
2925    /// # Arguments
2926    ///
2927    /// - `group_id` - the group the client is not authorized to access
2928    /// - `message` - the error message
2929    pub fn group_authorization_with_message(group_id: impl Into<String>, message: impl Into<String>) -> Self {
2930        Self::GroupAuthorization(GroupAuthorizationError::with_group_id(group_id, message))
2931    }
2932
2933    /// Creates an invalid group ID error, Java's `InvalidGroupIdException` (an
2934    /// `ApiException` carrying the code `Errors::InvalidGroupId`).
2935    ///
2936    /// Returned by group-management and offset-commit APIs when the consumer was
2937    /// constructed without a valid `group.id`.
2938    ///
2939    /// # Arguments
2940    ///
2941    /// - `message` - the error message
2942    pub fn invalid_group_id(message: impl Into<String>) -> Self {
2943        Self::InvalidGroupId(InvalidGroupIdError::new(message))
2944    }
2945
2946    /// Creates a throttling quota exceeded error, Java's
2947    /// `ThrottlingQuotaExceededException(int, String)`.
2948    ///
2949    /// # Arguments
2950    ///
2951    /// - `throttle_time_ms` - how long, in milliseconds, the client is throttled
2952    /// - `message` - the error message
2953    pub fn throttling_quota_exceeded(throttle_time_ms: i32, message: impl Into<String>) -> Self {
2954        Self::ThrottlingQuotaExceeded(ThrottlingQuotaExceededError::new(throttle_time_ms, message))
2955    }
2956
2957    /// Returns the throttle time carried by a
2958    /// [`ThrottlingQuotaExceeded`](Self::ThrottlingQuotaExceeded) error, Java's
2959    /// `ThrottlingQuotaExceededException.throttleTimeMs()`, or `None` for any other
2960    /// error.
2961    pub fn throttle_time_ms(&self) -> Option<i32> {
2962        match self {
2963            Self::ThrottlingQuotaExceeded(e) => Some(e.throttle_time_ms),
2964            _ => None,
2965        }
2966    }
2967
2968    /// Creates a buffer exhausted error, Java's `BufferExhaustedException`.
2969    ///
2970    /// # Arguments
2971    ///
2972    /// - `message` - the error message
2973    pub fn buffer_exhausted(message: impl Into<String>) -> Self {
2974        Self::ProducerBufferExhausted(ProducerBufferExhaustedError::new(message))
2975    }
2976
2977    /// Creates an illegal argument error, Java's `IllegalArgumentException`.
2978    ///
2979    /// # Arguments
2980    ///
2981    /// - `message` - the error message
2982    pub fn local_illegal_argument(message: impl Into<String>) -> Self {
2983        Self::LocalIllegalArgument(LocalIllegalArgumentError::new(message))
2984    }
2985
2986    // Java's three `ConfigException` constructors have an empty parameter-name
2987    // intersection and none is no-arg, so no factory below keeps the plain name
2988    // `config` — each takes its full parameter list as the suffix.
2989    // [`ConfigError::new`] is the one exception, and only because it is
2990    // macro-generated; see the note there.
2991
2992    /// Creates a configuration error, Java's `ConfigException(message)`: an invalid
2993    /// config value.
2994    ///
2995    /// Unlike [`local_illegal_argument`](Self::local_illegal_argument) this is inside
2996    /// the `KafkaException` hierarchy, so [`is_kafka_error`](Self::is_kafka_error) is
2997    /// `true` for it.
2998    ///
2999    /// # Arguments
3000    ///
3001    /// - `message` - the error message
3002    pub fn config_message(message: impl Into<String>) -> Self {
3003        Self::Config(ConfigError::new(message))
3004    }
3005
3006    /// Creates a configuration error naming the offending value and key, in Java's
3007    /// `ConfigException(name, value)` format.
3008    ///
3009    /// # Arguments
3010    ///
3011    /// - `name` - the name of the configuration
3012    /// - `value` - the value of the configuration
3013    pub fn config_name_value(name: impl std::fmt::Display, value: impl std::fmt::Display) -> Self {
3014        Self::Config(ConfigError::with_name_value(name, value))
3015    }
3016
3017    /// Creates a configuration error naming the value, key, and a detail message, in
3018    /// Java's `ConfigException(name, value, message)` format.
3019    ///
3020    /// # Arguments
3021    ///
3022    /// - `name` - the name of the configuration
3023    /// - `value` - the value of the configuration
3024    /// - `message` - why the value is invalid
3025    pub fn config_name_value_message(
3026        name: impl std::fmt::Display,
3027        value: impl std::fmt::Display,
3028        message: impl std::fmt::Display,
3029    ) -> Self {
3030        Self::Config(ConfigError::with_name_value_message(name, value, message))
3031    }
3032
3033    /// Creates an illegal state error, Java's `IllegalStateException`.
3034    ///
3035    /// # Arguments
3036    ///
3037    /// - `message` - the error message
3038    pub fn local_illegal_state(message: impl Into<String>) -> Self {
3039        Self::LocalIllegalState(LocalIllegalStateError::new(message))
3040    }
3041
3042    /// Creates an unsupported operation error, Java's
3043    /// `java.lang.UnsupportedOperationException`.
3044    ///
3045    /// Use [`Error::unsupported_version`] instead for
3046    /// `org.apache.kafka.common.errors.UnsupportedVersionException`, the wire-level
3047    /// class for an API version the broker does not support.
3048    ///
3049    /// # Arguments
3050    ///
3051    /// - `message` - the error message
3052    pub fn local_unsupported_operation(message: impl Into<String>) -> Self {
3053        Self::LocalUnsupportedOperation(LocalUnsupportedOperationError::new(message))
3054    }
3055
3056    /// Creates a timeout error, Java's `org.apache.kafka.common.errors.TimeoutException`.
3057    ///
3058    /// # Arguments
3059    ///
3060    /// - `message` - the error message
3061    pub fn timeout(message: impl Into<String>) -> Self {
3062        Self::Timeout(TimeoutError::new(message))
3063    }
3064
3065    /// Creates a record too large error, Java's `RecordTooLargeException`.
3066    ///
3067    /// # Arguments
3068    ///
3069    /// - `message` - the error message
3070    pub fn record_too_large(message: impl Into<String>) -> Self {
3071        Self::RecordTooLarge(RecordTooLargeError::new(message))
3072    }
3073
3074    /// Creates a correlation-id mismatch error, Java's
3075    /// `CorrelationIdMismatchException(String, int, int)`: an `IllegalStateException`,
3076    /// so outside the `KafkaException` hierarchy.
3077    ///
3078    /// # Arguments
3079    ///
3080    /// - `message` - the error message
3081    /// - `request_correlation_id` - the correlation id of the request sent
3082    /// - `response_correlation_id` - the correlation id the response carried
3083    pub fn correlation_id_mismatch(
3084        message: impl Into<String>,
3085        request_correlation_id: i32,
3086        response_correlation_id: i32,
3087    ) -> Self {
3088        Self::CorrelationIdMismatch(CorrelationIdMismatchError::new(
3089            message,
3090            request_correlation_id,
3091            response_correlation_id,
3092        ))
3093    }
3094
3095    /// Creates an invalid-receive error, Java's `InvalidReceiveException(String)`.
3096    ///
3097    /// The class is not public API (`common.network`), so this constructor is how code
3098    /// outside the crate, such as a test backend decoding an error sent over the wire,
3099    /// builds the variant.
3100    ///
3101    /// # Arguments
3102    ///
3103    /// - `message` - the error message
3104    pub fn invalid_receive(message: impl Into<String>) -> Self {
3105        Self::InvalidReceive(InvalidReceiveError::new(message))
3106    }
3107
3108    /// Creates a protocol-schema error, Java's `SchemaException(String)`.
3109    ///
3110    /// # Arguments
3111    ///
3112    /// - `message` - the error message
3113    pub fn schema(message: impl Into<String>) -> Self {
3114        Self::Schema(SchemaError::new(message))
3115    }
3116
3117    /// Creates a protocol-schema error carrying the failure that caused it, Java's
3118    /// `SchemaException(String, Throwable)`, used by `NetworkClient.parseResponse` to
3119    /// wrap a buffer underflow.
3120    ///
3121    /// The pair intersects on `{message}`, which is exactly [`schema`](Self::schema),
3122    /// so that one keeps the plain name and this is suffixed with the parameter beyond
3123    /// it.
3124    ///
3125    /// # Arguments
3126    ///
3127    /// - `message` - the error message
3128    /// - `source` - the error that caused this one, returned by [`source`](Self::source)
3129    pub fn schema_source(message: impl Into<String>, source: Error) -> Self {
3130        Self::Schema(SchemaError::with_source(message, source))
3131    }
3132
3133    /// Creates a serialization error, Java's `SerializationException`.
3134    ///
3135    /// # Arguments
3136    ///
3137    /// - `message` - the error message
3138    pub fn serialization(message: impl Into<String>) -> Self {
3139        Self::Serialization(SerializationError::new(message))
3140    }
3141
3142    /// Creates an unsupported version error, Java's `UnsupportedVersionException`.
3143    ///
3144    /// # Arguments
3145    ///
3146    /// - `message` - the error message
3147    pub fn unsupported_version(message: impl Into<String>) -> Self {
3148        Self::UnsupportedVersion(UnsupportedVersionError::new(message))
3149    }
3150
3151    /// Creates a wakeup error, Java's `WakeupException`.
3152    ///
3153    /// Returned from blocking `Consumer` operations (`poll`, `commit_sync`, `position`,
3154    /// etc.) when `wakeup()` is invoked from another task.
3155    ///
3156    /// # Arguments
3157    ///
3158    /// - `message` - the error message
3159    pub fn wakeup(message: impl Into<String>) -> Self {
3160        Self::Wakeup(WakeupError::new(message))
3161    }
3162
3163    /// Creates a concurrent modification error, Java's `ConcurrentModificationException`,
3164    /// which `KafkaConsumer.acquire()` throws when the consumer is accessed from more
3165    /// than one thread.
3166    ///
3167    /// # Arguments
3168    ///
3169    /// - `message` - the error message
3170    pub fn local_concurrent_modification(message: impl Into<String>) -> Self {
3171        Self::LocalConcurrentModification(LocalConcurrentModificationError::new(message))
3172    }
3173
3174    /// Creates a timed-out-waiting-on-a-future error, Java's
3175    /// `java.util.concurrent.TimeoutException` from `Future.get(timeout, unit)`.
3176    ///
3177    /// Use [`Error::timeout`] instead for
3178    /// `org.apache.kafka.common.errors.TimeoutException`, the retriable Kafka class the
3179    /// broker reports.
3180    ///
3181    /// # Arguments
3182    ///
3183    /// - `message` - the error message
3184    pub fn local_timeout(message: impl Into<String>) -> Self {
3185        Self::LocalTimeout(LocalTimeoutError::new(message))
3186    }
3187
3188    /// Creates the error a callback written in another language reports when it raised
3189    /// one of that language's errors. See [`LocalCallbackError`].
3190    ///
3191    /// # Arguments
3192    ///
3193    /// - `message` - the foreign error's text, for the client's logs
3194    /// - `opaque` - the binding's pointer to the foreign error, never dereferenced by
3195    ///   Rust and not owned by the error
3196    pub fn local_callback(message: impl Into<String>, opaque: *mut c_void) -> Self {
3197        Self::LocalCallback(LocalCallbackError::new(message, opaque))
3198    }
3199
3200    /// As [`local_callback`](Self::local_callback), but the error owns
3201    /// `opaque`: `release(opaque)` runs exactly once, when the last copy of the
3202    /// error drops, on whatever task or thread drops it. The FFI's
3203    /// `kafka_common_Error_local_callback` builds it when given a release
3204    /// function.
3205    ///
3206    /// # Safety
3207    ///
3208    /// `release` must be sound to call once with `opaque`, from any thread, at
3209    /// any time until the process exits.
3210    #[cfg_attr(not(any(feature = "ffi", test)), expect(dead_code))]
3211    pub(crate) unsafe fn local_callback_with_release(
3212        message: impl Into<String>,
3213        opaque: *mut c_void,
3214        release: crate::common::local_callback_error::ReleaseFn,
3215    ) -> Self {
3216        // SAFETY: forwarded: per this function's `# Safety`, `release` is sound to call once
3217        // with `opaque`, from any thread, at any time, as `with_release` requires.
3218        Self::LocalCallback(unsafe { LocalCallbackError::with_release(message, opaque, release) })
3219    }
3220
3221    /// Creates a transaction aborted error with Java's default message, Java's no-arg
3222    /// `TransactionAbortedException()`, whose message is
3223    /// `"Failing batch since transaction was aborted"`.
3224    ///
3225    /// The pair's parameter-name intersection is empty and this overload matches it,
3226    /// so it keeps the plain name.
3227    pub fn transaction_aborted() -> Self {
3228        Self::TransactionAborted(TransactionAbortedError::new("Failing batch since transaction was aborted"))
3229    }
3230
3231    /// Creates a transaction aborted error with a custom message, Java's
3232    /// `TransactionAbortedException(String)`.
3233    ///
3234    /// # Arguments
3235    ///
3236    /// - `message` - the error message
3237    pub fn transaction_aborted_message(message: impl Into<String>) -> Self {
3238        Self::TransactionAborted(TransactionAbortedError::new(message))
3239    }
3240
3241    /// Creates a record batch too large error, Java's `RecordBatchTooLargeException`.
3242    ///
3243    /// # Arguments
3244    ///
3245    /// - `message` - the error message
3246    pub fn record_batch_too_large(message: impl Into<String>) -> Self {
3247        Self::RecordBatchTooLarge(RecordBatchTooLargeError::new(message))
3248    }
3249
3250    // -- Base access -------------------------------------------------------
3251
3252    /// Returns the base [`KafkaError`] common to all variants, or `None` for variants
3253    /// that do not carry one (e.g. [`LocalIllegalArgument`](Self::LocalIllegalArgument),
3254    /// [`LocalIllegalState`](Self::LocalIllegalState)).
3255    pub fn kafka_error(&self) -> Option<&KafkaError> {
3256        match self {
3257            Self::KafkaError(e) => Some(e),
3258            // The only other payloads that embed one: Java gives these three
3259            // subclass state on top of the base, so they compose rather than
3260            // being declared by `kafka_error_type!`.
3261            Self::TopicAuthorization(e) => Some(e.kafka_error()),
3262            Self::InvalidTopic(e) => Some(e.kafka_error()),
3263            Self::GroupAuthorization(e) => Some(e.kafka_error()),
3264            // Every other variant is a `kafka_error_type!` declaration holding
3265            // only its message; it answers its code through [`ErrorCode`] and
3266            // its ancestry through [`ErrorHierarchy`], with no base to expose.
3267            // A catch-all is safe here precisely because there is nothing
3268            // variant-specific left to get wrong — unlike `message()`, which is
3269            // delegated so that a new payload must state its own answer.
3270            _ => None,
3271        }
3272    }
3273
3274    // -- Delegating methods ------------------------------------------------
3275
3276    /// The protocol error code.
3277    ///
3278    /// Returns [`Errors::UnknownServerError`] for variants without a
3279    /// [`KafkaError`].
3280    pub(crate) fn error(&self) -> Errors {
3281        // Delegated to the payload: Java associates a code with an exception
3282        // *class* (`Errors.forException`), not with an instance.
3283        ErrorCode::error(self)
3284    }
3285
3286    /// Returns the error message, Java's `Throwable.getMessage()`.
3287    ///
3288    /// A message-only error returns the text it was constructed with, and a payload
3289    /// wrapping a [`KafkaError`] returns its custom message if set, otherwise the
3290    /// default text for its error code.
3291    ///
3292    /// This is NOT what `to_string()` produces. [`std::fmt::Display`] translates
3293    /// `Throwable.toString()`, which Java renders as
3294    /// `getClass().getName() + ": " + getLocalizedMessage()`, so `Display` carries a
3295    /// class-name prefix and, for some payloads, extra subclass state. Use this method
3296    /// for log fields and equality assertions; use `Display` when rendering the error
3297    /// to a human.
3298    pub fn message(&self) -> &str {
3299        // UFCS: `self.message()` would resolve to this inherent method and recurse.
3300        ErrorMessage::message(self)
3301    }
3302
3303    /// Returns the error that caused this one, Java's `Throwable.getCause()`, or
3304    /// `None` when there is none.
3305    ///
3306    /// `getCause()` lives on `Throwable`, so every error can carry a cause: this
3307    /// answers for all of them. `None` is the common case, as Java's null default.
3308    ///
3309    /// [`std::error::Error::source`] returns the same value, so the standard library's
3310    /// chain-walking works on any [`Error`].
3311    pub fn source(&self) -> Option<&Error> {
3312        // UFCS: `self.source()` would resolve to this inherent method and recurse.
3313        ErrorSource::source(self)
3314    }
3315
3316    // -- Hierarchy predicates ----------------------------------------------
3317    //
3318    // Java's exception hierarchy is flattened into this enum, so each
3319    // intermediate class becomes a predicate. The answers
3320    // come from the variant's payload via `ErrorHierarchy`, which is crate
3321    // -internal; these forwarders are the public surface.
3322    //
3323    // Each MUST call the trait method through UFCS. `self.is_x()` inside
3324    // `Error::is_x` resolves back to this inherent method — inherent beats
3325    // trait — and recurses forever at run time while compiling cleanly.
3326
3327    /// Returns whether this is a Kafka error rather than a generic programming error.
3328    ///
3329    /// This enum flattens two families that Java keeps apart by class
3330    /// hierarchy: Kafka's own `KafkaException` tree, and the generic
3331    /// `java.lang` / `java.util` runtime exceptions that sit beside it as
3332    /// siblings rather than below it (`KafkaException` extends `RuntimeException`). This
3333    /// predicate recovers that distinction, mirroring Java's
3334    /// `t instanceof KafkaException`.
3335    ///
3336    /// Returns `false` for exactly the generic variants — the ones raised by
3337    /// misuse of the client rather than by Kafka itself:
3338    /// [`LocalIllegalArgument`](Self::LocalIllegalArgument),
3339    /// [`LocalIllegalState`](Self::LocalIllegalState),
3340    /// [`LocalConcurrentModification`](Self::LocalConcurrentModification),
3341    /// [`LocalTimeout`](Self::LocalTimeout) and
3342    /// [`LocalUnsupportedOperation`](Self::LocalUnsupportedOperation), plus
3343    /// [`LocalCallback`](Self::LocalCallback), a foreign callback's error, which
3344    /// the client wraps as Java wraps a listener's foreign `Throwable`.
3345    ///
3346    /// Everything else returns `true`: the `ApiException` subtypes,
3347    /// [`Serialization`](Self::Serialization), [`Wakeup`](Self::Wakeup) and the
3348    /// bare [`KafkaError`](Self::KafkaError) all map to `KafkaException`
3349    /// subclasses.
3350    ///
3351    /// **This is not a test for the [`KafkaError`](Self::KafkaError) variant.**
3352    /// That variant means "a bare `KafkaException`, no subclass"; this asks
3353    /// "inside the `KafkaException` hierarchy at all", which is true of
3354    /// `Timeout`, `TopicAuthorization` and most other variants too. Java has no
3355    /// `instanceof` test for "a bare `KafkaException` and no subclass" either.
3356    ///
3357    /// Beware the polarity difference against [`is_api_error`](Self::is_api_error):
3358    /// both return `true` for the in-hierarchy case, but they are not the same
3359    /// test — `Serialization` and `Wakeup` are Kafka errors that are NOT
3360    /// `ApiException`s, so they return `true` here and `false` there.
3361    ///
3362    /// Two call sites depend on this:
3363    /// `org.apache.kafka.clients.consumer.internals.ConsumerUtils#maybeWrapAsKafkaException`
3364    /// — a Kafka error passes through unchanged, a
3365    /// generic one gets wrapped in a new `KafkaException(message, t)` — and
3366    /// `FetchCollector`, whose Java `catch (KafkaException e)` cannot catch a
3367    /// generic error, so those propagate where Kafka errors are swallowed.
3368    pub fn is_kafka_error(&self) -> bool {
3369        ErrorHierarchy::is_kafka_error(self)
3370    }
3371
3372    /// Returns whether this error's Java class is `ApiException` or extends it.
3373    ///
3374    /// In Java, `ApiException` is a subclass of `KafkaException` representing
3375    /// errors from the Kafka API. In `KafkaProducer.doSend()`, `ApiException`s
3376    /// are caught and returned via a failed future (with callback invocation),
3377    /// while other exceptions propagate directly.
3378    ///
3379    /// `true` for every payload whose `extends:` list names `is_api_error` —
3380    /// which is every class carrying a protocol code, since `Errors.java` only
3381    /// names `ApiException` subclasses, plus the code-less concrete bases
3382    /// [`Api`](Self::Api), [`Authentication`](Self::Authentication) and
3383    /// [`Authorization`](Self::Authorization). Examples:
3384    /// [`InvalidTopic`](Self::InvalidTopic),
3385    /// [`RecordTooLarge`](Self::RecordTooLarge), [`Timeout`](Self::Timeout),
3386    /// [`TopicAuthorization`](Self::TopicAuthorization),
3387    /// [`GroupAuthorization`](Self::GroupAuthorization),
3388    /// [`ThrottlingQuotaExceeded`](Self::ThrottlingQuotaExceeded) and
3389    /// [`ProducerBufferExhausted`](Self::ProducerBufferExhausted).
3390    ///
3391    /// `false` for the bare [`KafkaError`](Self::KafkaError) — `KafkaException`
3392    /// is `ApiException`'s *parent*, not an instance of it, and since
3393    /// `Error::new` resolves every code to its own class that variant is now
3394    /// reached only for `Errors::None` and for
3395    /// [`Error::kafka`](Self::kafka). Also `false` for
3396    /// [`LocalIllegalArgument`](Self::LocalIllegalArgument) and
3397    /// [`LocalIllegalState`](Self::LocalIllegalState) (plain `RuntimeException`s),
3398    /// [`LocalConcurrentModification`](Self::LocalConcurrentModification), and for
3399    /// [`Serialization`](Self::Serialization) / [`Wakeup`](Self::Wakeup), which
3400    /// extend `KafkaException` directly without passing through `ApiException`.
3401    ///
3402    /// Not to be confused with [`is_kafka_error`](Self::is_kafka_error), which
3403    /// asks the broader question.
3404    pub fn is_api_error(&self) -> bool {
3405        ErrorHierarchy::is_api_error(self)
3406    }
3407
3408    /// Returns whether this error's Java class extends `RetriableException` — i.e. whether
3409    /// re-sending the failed request can succeed.
3410    ///
3411    /// The answer belongs to the payload, not to the enum: each error class
3412    /// names `is_retriable_error` in its `extends:` list, so the covered set is
3413    /// exactly the classes whose Java ancestry passes through
3414    /// `RetriableException` — directly, or via `RefreshRetriableException`,
3415    /// `InvalidMetadataException` or `TimeoutException`. [`Timeout`](Self::Timeout)
3416    /// is retriable (Java's `TimeoutException` extends `RetriableException`), as
3417    /// are [`ThrottlingQuotaExceeded`](Self::ThrottlingQuotaExceeded) and
3418    /// [`ProducerBufferExhausted`](Self::ProducerBufferExhausted) (through
3419    /// `BufferExhaustedException extends TimeoutException`).
3420    ///
3421    /// Since `Error::new` resolves every code to its own class, the set of
3422    /// *codes* answering `true` is pinned in both directions — against the Java
3423    /// `extends` chain, over every code — by `errors.rs`'s
3424    /// `test_retriable_errors_match_java_hierarchy`.
3425    ///
3426    /// The bare [`KafkaError`](Self::KafkaError) answers `false`
3427    /// (`KafkaException` is not a `RetriableException`), and so do
3428    /// [`LocalIllegalArgument`](Self::LocalIllegalArgument) and
3429    /// [`LocalIllegalState`](Self::LocalIllegalState).
3430    pub fn is_retriable_error(&self) -> bool {
3431        ErrorHierarchy::is_retriable_error(self)
3432    }
3433
3434    /// Returns whether this error's Java class extends `RefreshRetriableException` — retriable, and
3435    /// a metadata / coordinator refresh is what clears it.
3436    ///
3437    /// Fifteen payloads name it in their `extends:` list: the thirteen that also
3438    /// answer [`is_invalid_metadata_error`](Self::is_invalid_metadata_error)
3439    /// (`InvalidMetadataException extends RefreshRetriableException`), plus
3440    /// [`CoordinatorNotAvailable`](Self::CoordinatorNotAvailable) and
3441    /// [`NotCoordinator`](Self::NotCoordinator). All fifteen carry a protocol
3442    /// code, so the set is pinned in both directions over every code by
3443    /// `errors.rs`'s `test_hierarchy_predicates_match_java`.
3444    ///
3445    /// The bare [`KafkaError`](Self::KafkaError) answers `false`, as do the
3446    /// payloads carrying no protocol code.
3447    pub fn is_refresh_retriable_error(&self) -> bool {
3448        ErrorHierarchy::is_refresh_retriable_error(self)
3449    }
3450
3451    /// Returns whether this error's Java class extends `TimeoutException`.
3452    ///
3453    /// Wider than the [`Timeout`](Self::Timeout) variant:
3454    /// `BufferExhaustedException extends TimeoutException`, so
3455    /// [`ProducerBufferExhausted`](Self::ProducerBufferExhausted) answers `true`
3456    /// here too — matching Java, where `catch (TimeoutException e)` catches a
3457    /// buffer-pool exhaustion. To exclude that case, as a Java caller would with
3458    /// a preceding `catch (BufferExhaustedException e)`, also test
3459    /// [`is_producer_buffer_exhausted_error`](Self::is_producer_buffer_exhausted_error).
3460    ///
3461    /// Nested inside [`is_retriable_error`](Self::is_retriable_error).
3462    pub fn is_timeout_error(&self) -> bool {
3463        ErrorHierarchy::is_timeout_error(self)
3464    }
3465
3466    /// Returns whether this error's Java class extends `InvalidMetadataException` — the client's
3467    /// cached metadata may be stale.
3468    ///
3469    /// Nested inside [`is_refresh_retriable_error`](Self::is_refresh_retriable_error),
3470    /// which is nested inside [`is_retriable_error`](Self::is_retriable_error).
3471    /// Thirteen payloads name it, all of them code-carrying; the set is pinned in
3472    /// both directions over every code by `errors.rs`'s
3473    /// `test_hierarchy_predicates_match_java`.
3474    pub fn is_invalid_metadata_error(&self) -> bool {
3475        ErrorHierarchy::is_invalid_metadata_error(self)
3476    }
3477
3478    /// Returns whether this error's Java class extends `InvalidConfigurationException`.
3479    ///
3480    /// Wider than its name suggests: in Kafka 4.2 **both**
3481    /// `AuthenticationException` and `AuthorizationException` extend
3482    /// `InvalidConfigurationException` rather than `ApiException` directly, so
3483    /// every error answering `true` to
3484    /// [`is_authentication_error`](Self::is_authentication_error) or
3485    /// [`is_authorization_error`](Self::is_authorization_error) answers `true`
3486    /// here too. The remaining members are the configuration errors proper —
3487    /// `Errors::InvalidConfig`, `Errors::InvalidReplicationFactor`,
3488    /// `Errors::InvalidRequiredAcks`, `Errors::InvalidTopicError`,
3489    /// `Errors::RecordListTooLarge`, `Errors::UnsupportedForMessageFormat`
3490    /// and `Errors::UnsupportedVersion`.
3491    pub fn is_invalid_configuration_error(&self) -> bool {
3492        ErrorHierarchy::is_invalid_configuration_error(self)
3493    }
3494
3495    /// Returns whether this error's Java class extends `ApplicationRecoverableException` — the
3496    /// application can recover, but only by re-initialising its producer or rejoining its group;
3497    /// the current epoch or session is gone.
3498    ///
3499    /// 6 codes, covering the transaction and group-membership fencing paths:
3500    /// `Errors::FencedInstanceId`, `Errors::IllegalGeneration`,
3501    /// `Errors::InvalidProducerEpoch`, `Errors::InvalidProducerIdMapping`,
3502    /// `Errors::ProducerFenced` and `Errors::UnknownMemberId`.
3503    pub fn is_application_recoverable_error(&self) -> bool {
3504        ErrorHierarchy::is_application_recoverable_error(self)
3505    }
3506
3507    /// Returns whether this error's Java class extends `InvalidOffsetException`.
3508    ///
3509    /// `Errors::OffsetOutOfRange` is the only member carrying a protocol code;
3510    /// the sibling `NoOffsetForPartitionException` is raised client-side.
3511    pub fn is_invalid_offset_error(&self) -> bool {
3512        ErrorHierarchy::is_invalid_offset_error(self)
3513    }
3514
3515    /// Returns whether this error's Java class extends `OutOfOrderSequenceException`.
3516    ///
3517    /// Two codes: `Errors::OutOfOrderSequenceNumber` itself and
3518    /// `Errors::UnknownProducerId`, its only subclass.
3519    pub fn is_out_of_order_sequence_error(&self) -> bool {
3520        ErrorHierarchy::is_out_of_order_sequence_error(self)
3521    }
3522
3523    /// Returns whether this error's Java class extends
3524    /// `org.apache.kafka.clients.consumer.InvalidOffsetException` — no offset is usable for the
3525    /// partition.
3526    ///
3527    /// Covers
3528    /// [`ConsumerNoOffsetForPartition`](Self::ConsumerNoOffsetForPartition),
3529    /// [`ConsumerOffsetOutOfRange`](Self::ConsumerOffsetOutOfRange) and
3530    /// [`ConsumerLogTruncation`](Self::ConsumerLogTruncation) — the `Consumer`
3531    /// prefix marks the `clients.consumer` package's classes, so it is part of
3532    /// the variant name.
3533    ///
3534    /// Distinct from [`is_invalid_offset_error`](Self::is_invalid_offset_error),
3535    /// which tests `common.errors.InvalidOffsetException` — a different Java
3536    /// class with a different parent (`ApiException` rather than
3537    /// `KafkaException`). The wire code `OFFSET_OUT_OF_RANGE` produces that one;
3538    /// `KafkaConsumer::poll` raises these.
3539    pub fn is_consumer_invalid_offset_error(&self) -> bool {
3540        ErrorHierarchy::is_consumer_invalid_offset_error(self)
3541    }
3542
3543    /// Returns whether this error's Java class extends
3544    /// `org.apache.kafka.clients.consumer.OffsetOutOfRangeException`.
3545    ///
3546    /// Wider than the [`ConsumerOffsetOutOfRange`](Self::ConsumerOffsetOutOfRange)
3547    /// variant: `LogTruncationException` extends that class, so
3548    /// [`ConsumerLogTruncation`](Self::ConsumerLogTruncation) answers `true` too
3549    /// — matching Java, where `catch (OffsetOutOfRangeException e)` catches a
3550    /// log truncation.
3551    ///
3552    /// Nested inside
3553    /// [`is_consumer_invalid_offset_error`](Self::is_consumer_invalid_offset_error).
3554    /// Distinct from [`is_invalid_offset_error`](Self::is_invalid_offset_error),
3555    /// which tests the `common.errors` class of the same name.
3556    pub fn is_consumer_offset_out_of_range_error(&self) -> bool {
3557        ErrorHierarchy::is_consumer_offset_out_of_range_error(self)
3558    }
3559
3560    /// Returns whether this error's Java class extends `SerializationException`.
3561    ///
3562    /// No protocol code maps here — `SerializationException` and its subclass
3563    /// `RecordDeserializationException` are raised client-side — so only
3564    /// [`Serialization`](Self::Serialization) answers `true`. Note it is a
3565    /// `KafkaException` but NOT an `ApiException`, so
3566    /// [`is_api_error`](Self::is_api_error) is `false` for it.
3567    pub fn is_serialization_error(&self) -> bool {
3568        ErrorHierarchy::is_serialization_error(self)
3569    }
3570
3571    /// Returns whether this error's Java class extends `AuthenticationException`.
3572    ///
3573    /// Five payloads name it in their `extends:` list:
3574    /// [`Authentication`](Self::Authentication) — the concrete base class, which
3575    /// has no entry in `Errors` of its own but inherits
3576    /// `Errors::InvalidConfig` from `InvalidConfigurationException` — plus
3577    /// [`SaslAuthentication`](Self::SaslAuthentication),
3578    /// [`SslAuthentication`](Self::SslAuthentication),
3579    /// [`IllegalSaslState`](Self::IllegalSaslState) and
3580    /// [`UnsupportedSaslMechanism`](Self::UnsupportedSaslMechanism). Three of
3581    /// them carry a code (`SASL_AUTHENTICATION_FAILED`, `ILLEGAL_SASL_STATE`,
3582    /// `UNSUPPORTED_SASL_MECHANISM`) and that code set is pinned in both
3583    /// directions over every code by `errors.rs`'s
3584    /// `test_hierarchy_predicates_match_java`.
3585    ///
3586    /// A handshake failure detected locally is carried inside an `io::Error`
3587    /// (`common::network::authentication_io_error`) as the class it was raised
3588    /// as — [`SaslAuthentication`](Self::SaslAuthentication) for rejected
3589    /// credentials, [`SslAuthentication`](Self::SslAuthentication) for a rejected
3590    /// certificate — and reaches the application, and the producer's transaction
3591    /// manager, unchanged; each answers `true` here, and so to
3592    /// `request_utils::RequestUtils::is_fatal_error`.
3593    ///
3594    /// Nested inside
3595    /// [`is_invalid_configuration_error`](Self::is_invalid_configuration_error).
3596    pub fn is_authentication_error(&self) -> bool {
3597        ErrorHierarchy::is_authentication_error(self)
3598    }
3599
3600    /// Returns whether this error's Java class extends `AuthorizationException`.
3601    ///
3602    /// Six payloads name it in their `extends:` list:
3603    /// [`Authorization`](Self::Authorization) — the concrete base class, which
3604    /// has no entry in `Errors` of its own but inherits
3605    /// `Errors::InvalidConfig` from `InvalidConfigurationException` — plus the five
3606    /// that do carry one,
3607    /// [`TopicAuthorization`](Self::TopicAuthorization),
3608    /// [`GroupAuthorization`](Self::GroupAuthorization),
3609    /// [`ClusterAuthorization`](Self::ClusterAuthorization),
3610    /// [`TransactionalIdAuthorization`](Self::TransactionalIdAuthorization) and
3611    /// [`DelegationTokenAuthorization`](Self::DelegationTokenAuthorization).
3612    /// Those five codes are pinned in both directions over every code by
3613    /// `errors.rs`'s `test_hierarchy_predicates_match_java`; the bare
3614    /// [`KafkaError`](Self::KafkaError) answers `false`.
3615    ///
3616    /// Nested inside
3617    /// [`is_invalid_configuration_error`](Self::is_invalid_configuration_error).
3618    pub fn is_authorization_error(&self) -> bool {
3619        ErrorHierarchy::is_authorization_error(self)
3620    }
3621
3622    // -- Class predicates ------------------------------------------------
3623    //
3624    // One per variant, mirroring `ErrorHierarchy`'s class predicates: use these
3625    // instead of matching on a variant, so that a subclass a later Java release
3626    // adds — a new variant — still answers `true`.
3627
3628    /// Returns whether this error's Java class is, or extends,
3629    /// `java.lang.IllegalArgumentException`.
3630    ///
3631    /// Prefer this to matching [`Error::LocalIllegalArgument`](Self::LocalIllegalArgument): a
3632    /// variant match misses the subclasses a later Java release may add.
3633    pub fn is_local_illegal_argument_error(&self) -> bool {
3634        ErrorHierarchy::is_local_illegal_argument_error(self)
3635    }
3636
3637    /// Returns whether this error's Java class is, or extends, `java.lang.IllegalStateException`.
3638    ///
3639    /// Prefer this to matching [`Error::LocalIllegalState`](Self::LocalIllegalState): a variant
3640    /// match misses the subclasses a later Java release may add.
3641    pub fn is_local_illegal_state_error(&self) -> bool {
3642        ErrorHierarchy::is_local_illegal_state_error(self)
3643    }
3644
3645    /// Returns whether this error's Java class is, or extends,
3646    /// `java.util.ConcurrentModificationException`.
3647    ///
3648    /// Prefer this to matching
3649    /// [`Error::LocalConcurrentModification`](Self::LocalConcurrentModification): a variant match
3650    /// misses the subclasses a later Java release may add.
3651    pub fn is_local_concurrent_modification_error(&self) -> bool {
3652        ErrorHierarchy::is_local_concurrent_modification_error(self)
3653    }
3654
3655    /// Returns whether this error's Java class is, or extends,
3656    /// `java.util.concurrent.TimeoutException`.
3657    ///
3658    /// Prefer this to matching [`Error::LocalTimeout`](Self::LocalTimeout): a variant match misses
3659    /// the subclasses a later Java release may add.
3660    pub fn is_local_timeout_error(&self) -> bool {
3661        ErrorHierarchy::is_local_timeout_error(self)
3662    }
3663
3664    /// Returns whether this error's Java class is, or extends,
3665    /// `java.lang.UnsupportedOperationException`.
3666    ///
3667    /// Covers exactly [`Error::LocalUnsupportedOperation`](Self::LocalUnsupportedOperation), a
3668    /// plain `RuntimeException` beside `KafkaException`: it answers `false` to
3669    /// [`is_kafka_error`](Self::is_kafka_error), [`is_api_error`](Self::is_api_error) and
3670    /// [`is_retriable_error`](Self::is_retriable_error), and, unlike
3671    /// [`is_unsupported_version_error`](Self::is_unsupported_version_error) (the wire-level
3672    /// `UnsupportedVersionException`), it is not fatal.
3673    ///
3674    /// Prefer this to matching
3675    /// [`Error::LocalUnsupportedOperation`](Self::LocalUnsupportedOperation): a variant match
3676    /// misses the subclasses a later Java release may add.
3677    pub fn is_local_unsupported_operation_error(&self) -> bool {
3678        ErrorHierarchy::is_local_unsupported_operation_error(self)
3679    }
3680
3681    /// Returns whether this is an error raised by a callback written in another language
3682    /// ([`Error::LocalCallback`](Self::LocalCallback); no Java class).
3683    ///
3684    /// Covers exactly that variant. Like the `java.lang` runtime errors it is
3685    /// outside the Kafka hierarchy: [`is_kafka_error`](Self::is_kafka_error) and
3686    /// every other predicate answer `false` for it.
3687    pub fn is_local_callback_error(&self) -> bool {
3688        ErrorHierarchy::is_local_callback_error(self)
3689    }
3690
3691    /// Returns whether this error's Java class is, or extends,
3692    /// `org.apache.kafka.common.errors.AuthorizerNotReadyException`.
3693    ///
3694    /// Prefer this to matching [`Error::AuthorizerNotReady`](Self::AuthorizerNotReady): a variant
3695    /// match misses the subclasses a later Java release may add.
3696    pub fn is_authorizer_not_ready_error(&self) -> bool {
3697        ErrorHierarchy::is_authorizer_not_ready_error(self)
3698    }
3699
3700    /// Returns whether this error's Java class is, or extends,
3701    /// `org.apache.kafka.common.errors.BootstrapResolutionException`.
3702    ///
3703    /// Prefer this to matching [`Error::BootstrapResolution`](Self::BootstrapResolution): a variant
3704    /// match misses the subclasses a later Java release may add.
3705    pub fn is_bootstrap_resolution_error(&self) -> bool {
3706        ErrorHierarchy::is_bootstrap_resolution_error(self)
3707    }
3708
3709    /// Returns whether this error's Java class is, or extends,
3710    /// `org.apache.kafka.common.errors.BrokerIdNotRegisteredException`.
3711    ///
3712    /// Prefer this to matching [`Error::BrokerIdNotRegistered`](Self::BrokerIdNotRegistered): a
3713    /// variant match misses the subclasses a later Java release may add.
3714    pub fn is_broker_id_not_registered_error(&self) -> bool {
3715        ErrorHierarchy::is_broker_id_not_registered_error(self)
3716    }
3717
3718    /// Returns whether this error's Java class is, or extends,
3719    /// `org.apache.kafka.common.errors.BrokerNotAvailableException`.
3720    ///
3721    /// Prefer this to matching [`Error::BrokerNotAvailable`](Self::BrokerNotAvailable): a variant
3722    /// match misses the subclasses a later Java release may add.
3723    pub fn is_broker_not_available_error(&self) -> bool {
3724        ErrorHierarchy::is_broker_not_available_error(self)
3725    }
3726
3727    /// Returns whether this error's Java class is, or extends,
3728    /// `org.apache.kafka.clients.producer.BufferExhaustedException`.
3729    ///
3730    /// Prefer this to matching [`Error::ProducerBufferExhausted`](Self::ProducerBufferExhausted): a
3731    /// variant match misses the subclasses a later Java release may add.
3732    pub fn is_producer_buffer_exhausted_error(&self) -> bool {
3733        ErrorHierarchy::is_producer_buffer_exhausted_error(self)
3734    }
3735
3736    /// Returns whether this error's Java class is, or extends,
3737    /// `org.apache.kafka.common.errors.ClusterAuthorizationException`.
3738    ///
3739    /// Prefer this to matching [`Error::ClusterAuthorization`](Self::ClusterAuthorization): a
3740    /// variant match misses the subclasses a later Java release may add.
3741    pub fn is_cluster_authorization_error(&self) -> bool {
3742        ErrorHierarchy::is_cluster_authorization_error(self)
3743    }
3744
3745    /// Returns whether this error's Java class is, or extends,
3746    /// `org.apache.kafka.common.errors.ConcurrentTransactionsException`.
3747    ///
3748    /// Prefer this to matching [`Error::ConcurrentTransactions`](Self::ConcurrentTransactions): a
3749    /// variant match misses the subclasses a later Java release may add.
3750    pub fn is_concurrent_transactions_error(&self) -> bool {
3751        ErrorHierarchy::is_concurrent_transactions_error(self)
3752    }
3753
3754    /// Returns whether this error's Java class is, or extends,
3755    /// `org.apache.kafka.common.errors.ControllerIdNotRegisteredException`.
3756    ///
3757    /// Prefer this to matching [`Error::ControllerIdNotRegistered`](Self::ControllerIdNotRegistered): a variant
3758    /// match misses the subclasses a later Java release may add.
3759    pub fn is_controller_id_not_registered_error(&self) -> bool {
3760        ErrorHierarchy::is_controller_id_not_registered_error(self)
3761    }
3762
3763    /// Returns whether this error's Java class is, or extends,
3764    /// `org.apache.kafka.common.errors.ControllerMovedException`.
3765    ///
3766    /// Prefer this to matching [`Error::ControllerMoved`](Self::ControllerMoved): a variant match
3767    /// misses the subclasses a later Java release may add.
3768    pub fn is_controller_moved_error(&self) -> bool {
3769        ErrorHierarchy::is_controller_moved_error(self)
3770    }
3771
3772    /// Returns whether this error's Java class is, or extends,
3773    /// `org.apache.kafka.common.errors.CoordinatorLoadInProgressException`.
3774    ///
3775    /// Prefer this to matching
3776    /// [`Error::CoordinatorLoadInProgress`](Self::CoordinatorLoadInProgress): a variant match
3777    /// misses the subclasses a later Java release may add.
3778    pub fn is_coordinator_load_in_progress_error(&self) -> bool {
3779        ErrorHierarchy::is_coordinator_load_in_progress_error(self)
3780    }
3781
3782    /// Returns whether this error's Java class is, or extends,
3783    /// `org.apache.kafka.common.errors.CoordinatorNotAvailableException`.
3784    ///
3785    /// Prefer this to matching [`Error::CoordinatorNotAvailable`](Self::CoordinatorNotAvailable): a
3786    /// variant match misses the subclasses a later Java release may add.
3787    pub fn is_coordinator_not_available_error(&self) -> bool {
3788        ErrorHierarchy::is_coordinator_not_available_error(self)
3789    }
3790
3791    /// Returns whether this error's Java class is, or extends,
3792    /// `org.apache.kafka.common.requests.CorrelationIdMismatchException`.
3793    ///
3794    /// Prefer this to matching [`Error::CorrelationIdMismatch`](Self::CorrelationIdMismatch): a
3795    /// variant match misses the subclasses a later Java release may add.
3796    pub fn is_correlation_id_mismatch_error(&self) -> bool {
3797        ErrorHierarchy::is_correlation_id_mismatch_error(self)
3798    }
3799
3800    /// Returns whether this error's Java class is, or extends,
3801    /// `org.apache.kafka.common.errors.CorruptRecordException`.
3802    ///
3803    /// Prefer this to matching [`Error::CorruptRecord`](Self::CorruptRecord): a variant match
3804    /// misses the subclasses a later Java release may add.
3805    pub fn is_corrupt_record_error(&self) -> bool {
3806        ErrorHierarchy::is_corrupt_record_error(self)
3807    }
3808
3809    /// Returns whether this error's Java class is, or extends,
3810    /// `org.apache.kafka.common.errors.DelegationTokenAuthorizationException`.
3811    ///
3812    /// Prefer this to matching
3813    /// [`Error::DelegationTokenAuthorization`](Self::DelegationTokenAuthorization): a variant match
3814    /// misses the subclasses a later Java release may add.
3815    pub fn is_delegation_token_authorization_error(&self) -> bool {
3816        ErrorHierarchy::is_delegation_token_authorization_error(self)
3817    }
3818
3819    /// Returns whether this error's Java class is, or extends,
3820    /// `org.apache.kafka.common.errors.DelegationTokenDisabledException`.
3821    ///
3822    /// Prefer this to matching [`Error::DelegationTokenDisabled`](Self::DelegationTokenDisabled): a
3823    /// variant match misses the subclasses a later Java release may add.
3824    pub fn is_delegation_token_disabled_error(&self) -> bool {
3825        ErrorHierarchy::is_delegation_token_disabled_error(self)
3826    }
3827
3828    /// Returns whether this error's Java class is, or extends,
3829    /// `org.apache.kafka.common.errors.DelegationTokenExpiredException`.
3830    ///
3831    /// Prefer this to matching [`Error::DelegationTokenExpired`](Self::DelegationTokenExpired): a
3832    /// variant match misses the subclasses a later Java release may add.
3833    pub fn is_delegation_token_expired_error(&self) -> bool {
3834        ErrorHierarchy::is_delegation_token_expired_error(self)
3835    }
3836
3837    /// Returns whether this error's Java class is, or extends,
3838    /// `org.apache.kafka.common.errors.DelegationTokenNotFoundException`.
3839    ///
3840    /// Prefer this to matching [`Error::DelegationTokenNotFound`](Self::DelegationTokenNotFound): a
3841    /// variant match misses the subclasses a later Java release may add.
3842    pub fn is_delegation_token_not_found_error(&self) -> bool {
3843        ErrorHierarchy::is_delegation_token_not_found_error(self)
3844    }
3845
3846    /// Returns whether this error's Java class is, or extends,
3847    /// `org.apache.kafka.common.errors.DelegationTokenOwnerMismatchException`.
3848    ///
3849    /// Prefer this to matching
3850    /// [`Error::DelegationTokenOwnerMismatch`](Self::DelegationTokenOwnerMismatch): a variant match
3851    /// misses the subclasses a later Java release may add.
3852    pub fn is_delegation_token_owner_mismatch_error(&self) -> bool {
3853        ErrorHierarchy::is_delegation_token_owner_mismatch_error(self)
3854    }
3855
3856    /// Returns whether this error's Java class is, or extends,
3857    /// `org.apache.kafka.common.errors.DisconnectException`.
3858    ///
3859    /// Prefer this to matching [`Error::Disconnect`](Self::Disconnect): a variant match misses the
3860    /// subclasses a later Java release may add.
3861    pub fn is_disconnect_error(&self) -> bool {
3862        ErrorHierarchy::is_disconnect_error(self)
3863    }
3864
3865    /// Returns whether this error's Java class is, or extends,
3866    /// `org.apache.kafka.common.errors.DuplicateBrokerRegistrationException`.
3867    ///
3868    /// Prefer this to matching
3869    /// [`Error::DuplicateBrokerRegistration`](Self::DuplicateBrokerRegistration): a variant match
3870    /// misses the subclasses a later Java release may add.
3871    pub fn is_duplicate_broker_registration_error(&self) -> bool {
3872        ErrorHierarchy::is_duplicate_broker_registration_error(self)
3873    }
3874
3875    /// Returns whether this error's Java class is, or extends,
3876    /// `org.apache.kafka.common.errors.DuplicateResourceException`.
3877    ///
3878    /// Prefer this to matching [`Error::DuplicateResource`](Self::DuplicateResource): a variant
3879    /// match misses the subclasses a later Java release may add.
3880    pub fn is_duplicate_resource_error(&self) -> bool {
3881        ErrorHierarchy::is_duplicate_resource_error(self)
3882    }
3883
3884    /// Returns whether this error's Java class is, or extends,
3885    /// `org.apache.kafka.common.errors.DuplicateSequenceException`.
3886    ///
3887    /// Prefer this to matching [`Error::DuplicateSequence`](Self::DuplicateSequence): a variant
3888    /// match misses the subclasses a later Java release may add.
3889    pub fn is_duplicate_sequence_error(&self) -> bool {
3890        ErrorHierarchy::is_duplicate_sequence_error(self)
3891    }
3892
3893    /// Returns whether this error's Java class is, or extends,
3894    /// `org.apache.kafka.common.errors.DuplicateVoterException`.
3895    ///
3896    /// Prefer this to matching [`Error::DuplicateVoter`](Self::DuplicateVoter): a variant match
3897    /// misses the subclasses a later Java release may add.
3898    pub fn is_duplicate_voter_error(&self) -> bool {
3899        ErrorHierarchy::is_duplicate_voter_error(self)
3900    }
3901
3902    /// Returns whether this error's Java class is, or extends,
3903    /// `org.apache.kafka.common.errors.ElectionNotNeededException`.
3904    ///
3905    /// Prefer this to matching [`Error::ElectionNotNeeded`](Self::ElectionNotNeeded): a variant
3906    /// match misses the subclasses a later Java release may add.
3907    pub fn is_election_not_needed_error(&self) -> bool {
3908        ErrorHierarchy::is_election_not_needed_error(self)
3909    }
3910
3911    /// Returns whether this error's Java class is, or extends,
3912    /// `org.apache.kafka.common.errors.EligibleLeadersNotAvailableException`.
3913    ///
3914    /// Prefer this to matching
3915    /// [`Error::EligibleLeadersNotAvailable`](Self::EligibleLeadersNotAvailable): a variant match
3916    /// misses the subclasses a later Java release may add.
3917    pub fn is_eligible_leaders_not_available_error(&self) -> bool {
3918        ErrorHierarchy::is_eligible_leaders_not_available_error(self)
3919    }
3920
3921    /// Returns whether this error's Java class is, or extends,
3922    /// `org.apache.kafka.common.errors.FeatureUpdateFailedException`.
3923    ///
3924    /// Prefer this to matching [`Error::FeatureUpdateFailed`](Self::FeatureUpdateFailed): a variant
3925    /// match misses the subclasses a later Java release may add.
3926    pub fn is_feature_update_failed_error(&self) -> bool {
3927        ErrorHierarchy::is_feature_update_failed_error(self)
3928    }
3929
3930    /// Returns whether this error's Java class is, or extends,
3931    /// `org.apache.kafka.common.errors.FencedInstanceIdException`.
3932    ///
3933    /// Prefer this to matching [`Error::FencedInstanceId`](Self::FencedInstanceId): a variant match
3934    /// misses the subclasses a later Java release may add.
3935    pub fn is_fenced_instance_id_error(&self) -> bool {
3936        ErrorHierarchy::is_fenced_instance_id_error(self)
3937    }
3938
3939    /// Returns whether this error's Java class is, or extends,
3940    /// `org.apache.kafka.common.errors.FencedLeaderEpochException`.
3941    ///
3942    /// Prefer this to matching [`Error::FencedLeaderEpoch`](Self::FencedLeaderEpoch): a variant
3943    /// match misses the subclasses a later Java release may add.
3944    pub fn is_fenced_leader_epoch_error(&self) -> bool {
3945        ErrorHierarchy::is_fenced_leader_epoch_error(self)
3946    }
3947
3948    /// Returns whether this error's Java class is, or extends,
3949    /// `org.apache.kafka.common.errors.FencedMemberEpochException`.
3950    ///
3951    /// Prefer this to matching [`Error::FencedMemberEpoch`](Self::FencedMemberEpoch): a variant
3952    /// match misses the subclasses a later Java release may add.
3953    pub fn is_fenced_member_epoch_error(&self) -> bool {
3954        ErrorHierarchy::is_fenced_member_epoch_error(self)
3955    }
3956
3957    /// Returns whether this error's Java class is, or extends,
3958    /// `org.apache.kafka.common.errors.FencedStateEpochException`.
3959    ///
3960    /// Prefer this to matching [`Error::FencedStateEpoch`](Self::FencedStateEpoch): a variant match
3961    /// misses the subclasses a later Java release may add.
3962    pub fn is_fenced_state_epoch_error(&self) -> bool {
3963        ErrorHierarchy::is_fenced_state_epoch_error(self)
3964    }
3965
3966    /// Returns whether this error's Java class is, or extends,
3967    /// `org.apache.kafka.common.errors.FetchSessionIdNotFoundException`.
3968    ///
3969    /// Prefer this to matching [`Error::FetchSessionIdNotFound`](Self::FetchSessionIdNotFound): a
3970    /// variant match misses the subclasses a later Java release may add.
3971    pub fn is_fetch_session_id_not_found_error(&self) -> bool {
3972        ErrorHierarchy::is_fetch_session_id_not_found_error(self)
3973    }
3974
3975    /// Returns whether this error's Java class is, or extends,
3976    /// `org.apache.kafka.common.errors.FetchSessionTopicIdException`.
3977    ///
3978    /// Prefer this to matching [`Error::FetchSessionTopicId`](Self::FetchSessionTopicId): a variant
3979    /// match misses the subclasses a later Java release may add.
3980    pub fn is_fetch_session_topic_id_error(&self) -> bool {
3981        ErrorHierarchy::is_fetch_session_topic_id_error(self)
3982    }
3983
3984    /// Returns whether this error's Java class is, or extends,
3985    /// `org.apache.kafka.common.errors.GroupAuthorizationException`.
3986    ///
3987    /// Prefer this to matching [`Error::GroupAuthorization`](Self::GroupAuthorization): a variant
3988    /// match misses the subclasses a later Java release may add.
3989    pub fn is_group_authorization_error(&self) -> bool {
3990        ErrorHierarchy::is_group_authorization_error(self)
3991    }
3992
3993    /// Returns whether this error's Java class is, or extends,
3994    /// `org.apache.kafka.common.errors.GroupDeletionFailedException`.
3995    ///
3996    /// Prefer this to matching [`Error::GroupDeletionFailed`](Self::GroupDeletionFailed): a variant
3997    /// match misses the subclasses a later Java release may add.
3998    pub fn is_group_deletion_failed_error(&self) -> bool {
3999        ErrorHierarchy::is_group_deletion_failed_error(self)
4000    }
4001
4002    /// Returns whether this error's Java class is, or extends,
4003    /// `org.apache.kafka.common.errors.GroupIdNotFoundException`.
4004    ///
4005    /// Prefer this to matching [`Error::GroupIdNotFound`](Self::GroupIdNotFound): a variant match
4006    /// misses the subclasses a later Java release may add.
4007    pub fn is_group_id_not_found_error(&self) -> bool {
4008        ErrorHierarchy::is_group_id_not_found_error(self)
4009    }
4010
4011    /// Returns whether this error's Java class is, or extends,
4012    /// `org.apache.kafka.common.errors.GroupMaxSizeReachedException`.
4013    ///
4014    /// Prefer this to matching [`Error::GroupMaxSizeReached`](Self::GroupMaxSizeReached): a variant
4015    /// match misses the subclasses a later Java release may add.
4016    pub fn is_group_max_size_reached_error(&self) -> bool {
4017        ErrorHierarchy::is_group_max_size_reached_error(self)
4018    }
4019
4020    /// Returns whether this error's Java class is, or extends,
4021    /// `org.apache.kafka.common.errors.GroupNotEmptyException`.
4022    ///
4023    /// Prefer this to matching [`Error::GroupNotEmpty`](Self::GroupNotEmpty): a variant match
4024    /// misses the subclasses a later Java release may add.
4025    pub fn is_group_not_empty_error(&self) -> bool {
4026        ErrorHierarchy::is_group_not_empty_error(self)
4027    }
4028
4029    /// Returns whether this error's Java class is, or extends,
4030    /// `org.apache.kafka.common.errors.GroupSubscribedToTopicException`.
4031    ///
4032    /// Prefer this to matching [`Error::GroupSubscribedToTopic`](Self::GroupSubscribedToTopic): a
4033    /// variant match misses the subclasses a later Java release may add.
4034    pub fn is_group_subscribed_to_topic_error(&self) -> bool {
4035        ErrorHierarchy::is_group_subscribed_to_topic_error(self)
4036    }
4037
4038    /// Returns whether this error's Java class is, or extends,
4039    /// `org.apache.kafka.common.errors.IllegalGenerationException`.
4040    ///
4041    /// Prefer this to matching [`Error::IllegalGeneration`](Self::IllegalGeneration): a variant
4042    /// match misses the subclasses a later Java release may add.
4043    pub fn is_illegal_generation_error(&self) -> bool {
4044        ErrorHierarchy::is_illegal_generation_error(self)
4045    }
4046
4047    /// Returns whether this error's Java class is, or extends,
4048    /// `org.apache.kafka.common.errors.IllegalSaslStateException`.
4049    ///
4050    /// Prefer this to matching [`Error::IllegalSaslState`](Self::IllegalSaslState): a variant match
4051    /// misses the subclasses a later Java release may add.
4052    pub fn is_illegal_sasl_state_error(&self) -> bool {
4053        ErrorHierarchy::is_illegal_sasl_state_error(self)
4054    }
4055
4056    /// Returns whether this error's Java class is, or extends,
4057    /// `org.apache.kafka.common.errors.InconsistentClusterIdException`.
4058    ///
4059    /// Prefer this to matching [`Error::InconsistentClusterId`](Self::InconsistentClusterId): a
4060    /// variant match misses the subclasses a later Java release may add.
4061    pub fn is_inconsistent_cluster_id_error(&self) -> bool {
4062        ErrorHierarchy::is_inconsistent_cluster_id_error(self)
4063    }
4064
4065    /// Returns whether this error's Java class is, or extends,
4066    /// `org.apache.kafka.common.errors.InconsistentGroupProtocolException`.
4067    ///
4068    /// Prefer this to matching
4069    /// [`Error::InconsistentGroupProtocol`](Self::InconsistentGroupProtocol): a variant match
4070    /// misses the subclasses a later Java release may add.
4071    pub fn is_inconsistent_group_protocol_error(&self) -> bool {
4072        ErrorHierarchy::is_inconsistent_group_protocol_error(self)
4073    }
4074
4075    /// Returns whether this error's Java class is, or extends,
4076    /// `org.apache.kafka.common.errors.InconsistentTopicIdException`.
4077    ///
4078    /// Prefer this to matching [`Error::InconsistentTopicId`](Self::InconsistentTopicId): a variant
4079    /// match misses the subclasses a later Java release may add.
4080    pub fn is_inconsistent_topic_id_error(&self) -> bool {
4081        ErrorHierarchy::is_inconsistent_topic_id_error(self)
4082    }
4083
4084    /// Returns whether this error's Java class is, or extends,
4085    /// `org.apache.kafka.common.errors.InconsistentVoterSetException`.
4086    ///
4087    /// Prefer this to matching [`Error::InconsistentVoterSet`](Self::InconsistentVoterSet): a
4088    /// variant match misses the subclasses a later Java release may add.
4089    pub fn is_inconsistent_voter_set_error(&self) -> bool {
4090        ErrorHierarchy::is_inconsistent_voter_set_error(self)
4091    }
4092
4093    /// Returns whether this error's Java class is, or extends,
4094    /// `org.apache.kafka.common.errors.IneligibleReplicaException`.
4095    ///
4096    /// Prefer this to matching [`Error::IneligibleReplica`](Self::IneligibleReplica): a variant
4097    /// match misses the subclasses a later Java release may add.
4098    pub fn is_ineligible_replica_error(&self) -> bool {
4099        ErrorHierarchy::is_ineligible_replica_error(self)
4100    }
4101
4102    /// Returns whether this error's Java class is, or extends,
4103    /// `org.apache.kafka.common.errors.InterruptException`.
4104    ///
4105    /// Prefer this to matching [`Error::Interrupt`](Self::Interrupt): a variant match misses the
4106    /// subclasses a later Java release may add.
4107    pub fn is_interrupt_error(&self) -> bool {
4108        ErrorHierarchy::is_interrupt_error(self)
4109    }
4110
4111    /// Returns whether this error's Java class is, or extends,
4112    /// `org.apache.kafka.common.errors.InvalidCommitOffsetSizeException`.
4113    ///
4114    /// Prefer this to matching [`Error::InvalidCommitOffsetSize`](Self::InvalidCommitOffsetSize): a
4115    /// variant match misses the subclasses a later Java release may add.
4116    pub fn is_invalid_commit_offset_size_error(&self) -> bool {
4117        ErrorHierarchy::is_invalid_commit_offset_size_error(self)
4118    }
4119
4120    /// Returns whether this error's Java class is, or extends,
4121    /// `org.apache.kafka.common.errors.InvalidFetchSessionEpochException`.
4122    ///
4123    /// Prefer this to matching [`Error::InvalidFetchSessionEpoch`](Self::InvalidFetchSessionEpoch):
4124    /// a variant match misses the subclasses a later Java release may add.
4125    pub fn is_invalid_fetch_session_epoch_error(&self) -> bool {
4126        ErrorHierarchy::is_invalid_fetch_session_epoch_error(self)
4127    }
4128
4129    /// Returns whether this error's Java class is, or extends,
4130    /// `org.apache.kafka.common.errors.InvalidFetchSizeException`.
4131    ///
4132    /// Prefer this to matching [`Error::InvalidFetchSize`](Self::InvalidFetchSize): a variant match
4133    /// misses the subclasses a later Java release may add.
4134    pub fn is_invalid_fetch_size_error(&self) -> bool {
4135        ErrorHierarchy::is_invalid_fetch_size_error(self)
4136    }
4137
4138    /// Returns whether this error's Java class is, or extends,
4139    /// `org.apache.kafka.common.errors.InvalidGroupIdException`.
4140    ///
4141    /// Prefer this to matching [`Error::InvalidGroupId`](Self::InvalidGroupId): a variant match
4142    /// misses the subclasses a later Java release may add.
4143    pub fn is_invalid_group_id_error(&self) -> bool {
4144        ErrorHierarchy::is_invalid_group_id_error(self)
4145    }
4146
4147    /// Returns whether this error's Java class is, or extends,
4148    /// `org.apache.kafka.common.errors.InvalidPartitionsException`.
4149    ///
4150    /// Prefer this to matching [`Error::InvalidPartitions`](Self::InvalidPartitions): a variant
4151    /// match misses the subclasses a later Java release may add.
4152    pub fn is_invalid_partitions_error(&self) -> bool {
4153        ErrorHierarchy::is_invalid_partitions_error(self)
4154    }
4155
4156    /// Returns whether this error's Java class is, or extends,
4157    /// `org.apache.kafka.common.errors.InvalidPidMappingException`.
4158    ///
4159    /// Prefer this to matching [`Error::InvalidPidMapping`](Self::InvalidPidMapping): a variant
4160    /// match misses the subclasses a later Java release may add.
4161    pub fn is_invalid_pid_mapping_error(&self) -> bool {
4162        ErrorHierarchy::is_invalid_pid_mapping_error(self)
4163    }
4164
4165    /// Returns whether this error's Java class is, or extends,
4166    /// `org.apache.kafka.common.errors.InvalidPrincipalTypeException`.
4167    ///
4168    /// Prefer this to matching [`Error::InvalidPrincipalType`](Self::InvalidPrincipalType): a
4169    /// variant match misses the subclasses a later Java release may add.
4170    pub fn is_invalid_principal_type_error(&self) -> bool {
4171        ErrorHierarchy::is_invalid_principal_type_error(self)
4172    }
4173
4174    /// Returns whether this error's Java class is, or extends,
4175    /// `org.apache.kafka.common.errors.InvalidProducerEpochException`.
4176    ///
4177    /// Prefer this to matching [`Error::InvalidProducerEpoch`](Self::InvalidProducerEpoch): a
4178    /// variant match misses the subclasses a later Java release may add.
4179    pub fn is_invalid_producer_epoch_error(&self) -> bool {
4180        ErrorHierarchy::is_invalid_producer_epoch_error(self)
4181    }
4182
4183    /// Returns whether this error's Java class is, or extends,
4184    /// `org.apache.kafka.common.InvalidRecordException`.
4185    ///
4186    /// Prefer this to matching [`Error::InvalidRecord`](Self::InvalidRecord): a variant match
4187    /// misses the subclasses a later Java release may add.
4188    pub fn is_invalid_record_error(&self) -> bool {
4189        ErrorHierarchy::is_invalid_record_error(self)
4190    }
4191
4192    /// Returns whether this error's Java class is, or extends,
4193    /// `org.apache.kafka.common.errors.InvalidRecordStateException`.
4194    ///
4195    /// Prefer this to matching [`Error::InvalidRecordState`](Self::InvalidRecordState): a variant
4196    /// match misses the subclasses a later Java release may add.
4197    pub fn is_invalid_record_state_error(&self) -> bool {
4198        ErrorHierarchy::is_invalid_record_state_error(self)
4199    }
4200
4201    /// Returns whether this error's Java class is, or extends,
4202    /// `org.apache.kafka.common.errors.InvalidRegistrationException`.
4203    ///
4204    /// Prefer this to matching [`Error::InvalidRegistration`](Self::InvalidRegistration): a variant
4205    /// match misses the subclasses a later Java release may add.
4206    pub fn is_invalid_registration_error(&self) -> bool {
4207        ErrorHierarchy::is_invalid_registration_error(self)
4208    }
4209
4210    /// Returns whether this error's Java class is, or extends,
4211    /// `org.apache.kafka.common.errors.InvalidRegularExpression`.
4212    ///
4213    /// Prefer this to matching [`Error::InvalidRegularExpression`](Self::InvalidRegularExpression):
4214    /// a variant match misses the subclasses a later Java release may add.
4215    pub fn is_invalid_regular_expression_error(&self) -> bool {
4216        ErrorHierarchy::is_invalid_regular_expression_error(self)
4217    }
4218
4219    /// Returns whether this error's Java class is, or extends,
4220    /// `org.apache.kafka.common.errors.InvalidReplicaAssignmentException`.
4221    ///
4222    /// Prefer this to matching [`Error::InvalidReplicaAssignment`](Self::InvalidReplicaAssignment):
4223    /// a variant match misses the subclasses a later Java release may add.
4224    pub fn is_invalid_replica_assignment_error(&self) -> bool {
4225        ErrorHierarchy::is_invalid_replica_assignment_error(self)
4226    }
4227
4228    /// Returns whether this error's Java class is, or extends,
4229    /// `org.apache.kafka.common.errors.InvalidReplicationFactorException`.
4230    ///
4231    /// Prefer this to matching [`Error::InvalidReplicationFactor`](Self::InvalidReplicationFactor):
4232    /// a variant match misses the subclasses a later Java release may add.
4233    pub fn is_invalid_replication_factor_error(&self) -> bool {
4234        ErrorHierarchy::is_invalid_replication_factor_error(self)
4235    }
4236
4237    /// Returns whether this error's Java class is, or extends,
4238    /// `org.apache.kafka.common.errors.InvalidRequestException`.
4239    ///
4240    /// Prefer this to matching [`Error::InvalidRequest`](Self::InvalidRequest): a variant match
4241    /// misses the subclasses a later Java release may add.
4242    pub fn is_invalid_request_error(&self) -> bool {
4243        ErrorHierarchy::is_invalid_request_error(self)
4244    }
4245
4246    /// Returns whether this error's Java class is, or extends,
4247    /// `org.apache.kafka.common.errors.InvalidRequiredAcksException`.
4248    ///
4249    /// Prefer this to matching [`Error::InvalidRequiredAcks`](Self::InvalidRequiredAcks): a variant
4250    /// match misses the subclasses a later Java release may add.
4251    pub fn is_invalid_required_acks_error(&self) -> bool {
4252        ErrorHierarchy::is_invalid_required_acks_error(self)
4253    }
4254
4255    /// Returns whether this error's Java class is, or extends,
4256    /// `org.apache.kafka.common.errors.InvalidSessionTimeoutException`.
4257    ///
4258    /// Prefer this to matching [`Error::InvalidSessionTimeout`](Self::InvalidSessionTimeout): a
4259    /// variant match misses the subclasses a later Java release may add.
4260    pub fn is_invalid_session_timeout_error(&self) -> bool {
4261        ErrorHierarchy::is_invalid_session_timeout_error(self)
4262    }
4263
4264    /// Returns whether this error's Java class is, or extends,
4265    /// `org.apache.kafka.common.errors.InvalidShareSessionEpochException`.
4266    ///
4267    /// Prefer this to matching [`Error::InvalidShareSessionEpoch`](Self::InvalidShareSessionEpoch):
4268    /// a variant match misses the subclasses a later Java release may add.
4269    pub fn is_invalid_share_session_epoch_error(&self) -> bool {
4270        ErrorHierarchy::is_invalid_share_session_epoch_error(self)
4271    }
4272
4273    /// Returns whether this error's Java class is, or extends,
4274    /// `org.apache.kafka.common.errors.InvalidTimestampException`.
4275    ///
4276    /// Prefer this to matching [`Error::InvalidTimestamp`](Self::InvalidTimestamp): a variant match
4277    /// misses the subclasses a later Java release may add.
4278    pub fn is_invalid_timestamp_error(&self) -> bool {
4279        ErrorHierarchy::is_invalid_timestamp_error(self)
4280    }
4281
4282    /// Returns whether this error's Java class is, or extends,
4283    /// `org.apache.kafka.common.errors.InvalidTopicException`.
4284    ///
4285    /// Prefer this to matching [`Error::InvalidTopic`](Self::InvalidTopic): a variant match misses
4286    /// the subclasses a later Java release may add.
4287    pub fn is_invalid_topic_error(&self) -> bool {
4288        ErrorHierarchy::is_invalid_topic_error(self)
4289    }
4290
4291    /// Returns whether this error's Java class is, or extends,
4292    /// `org.apache.kafka.common.errors.InvalidTxnStateException`.
4293    ///
4294    /// Prefer this to matching [`Error::InvalidTxnState`](Self::InvalidTxnState): a variant match
4295    /// misses the subclasses a later Java release may add.
4296    pub fn is_invalid_txn_state_error(&self) -> bool {
4297        ErrorHierarchy::is_invalid_txn_state_error(self)
4298    }
4299
4300    /// Returns whether this error's Java class is, or extends,
4301    /// `org.apache.kafka.common.errors.InvalidTxnTimeoutException`.
4302    ///
4303    /// Prefer this to matching [`Error::InvalidTxnTimeout`](Self::InvalidTxnTimeout): a variant
4304    /// match misses the subclasses a later Java release may add.
4305    pub fn is_invalid_txn_timeout_error(&self) -> bool {
4306        ErrorHierarchy::is_invalid_txn_timeout_error(self)
4307    }
4308
4309    /// Returns whether this error's Java class is, or extends,
4310    /// `org.apache.kafka.common.errors.InvalidUpdateVersionException`.
4311    ///
4312    /// Prefer this to matching [`Error::InvalidUpdateVersion`](Self::InvalidUpdateVersion): a
4313    /// variant match misses the subclasses a later Java release may add.
4314    pub fn is_invalid_update_version_error(&self) -> bool {
4315        ErrorHierarchy::is_invalid_update_version_error(self)
4316    }
4317
4318    /// Returns whether this error's Java class is, or extends,
4319    /// `org.apache.kafka.common.errors.InvalidVoterKeyException`.
4320    ///
4321    /// Prefer this to matching [`Error::InvalidVoterKey`](Self::InvalidVoterKey): a variant match
4322    /// misses the subclasses a later Java release may add.
4323    pub fn is_invalid_voter_key_error(&self) -> bool {
4324        ErrorHierarchy::is_invalid_voter_key_error(self)
4325    }
4326
4327    /// Returns whether this error's Java class is, or extends,
4328    /// `org.apache.kafka.common.errors.KafkaStorageException`.
4329    ///
4330    /// Prefer this to matching [`Error::KafkaStorage`](Self::KafkaStorage): a variant match misses
4331    /// the subclasses a later Java release may add.
4332    pub fn is_kafka_storage_error(&self) -> bool {
4333        ErrorHierarchy::is_kafka_storage_error(self)
4334    }
4335
4336    /// Returns whether this error's Java class is, or extends,
4337    /// `org.apache.kafka.common.errors.LeaderNotAvailableException`.
4338    ///
4339    /// Prefer this to matching [`Error::LeaderNotAvailable`](Self::LeaderNotAvailable): a variant
4340    /// match misses the subclasses a later Java release may add.
4341    pub fn is_leader_not_available_error(&self) -> bool {
4342        ErrorHierarchy::is_leader_not_available_error(self)
4343    }
4344
4345    /// Returns whether this error's Java class is, or extends,
4346    /// `org.apache.kafka.common.errors.ListenerNotFoundException`.
4347    ///
4348    /// Prefer this to matching [`Error::ListenerNotFound`](Self::ListenerNotFound): a variant match
4349    /// misses the subclasses a later Java release may add.
4350    pub fn is_listener_not_found_error(&self) -> bool {
4351        ErrorHierarchy::is_listener_not_found_error(self)
4352    }
4353
4354    /// Returns whether this error's Java class is, or extends,
4355    /// `org.apache.kafka.common.errors.LogDirNotFoundException`.
4356    ///
4357    /// Prefer this to matching [`Error::LogDirNotFound`](Self::LogDirNotFound): a variant match
4358    /// misses the subclasses a later Java release may add.
4359    pub fn is_log_dir_not_found_error(&self) -> bool {
4360        ErrorHierarchy::is_log_dir_not_found_error(self)
4361    }
4362
4363    /// Returns whether this error's Java class is, or extends,
4364    /// `org.apache.kafka.common.errors.MemberIdRequiredException`.
4365    ///
4366    /// Prefer this to matching [`Error::MemberIdRequired`](Self::MemberIdRequired): a variant match
4367    /// misses the subclasses a later Java release may add.
4368    pub fn is_member_id_required_error(&self) -> bool {
4369        ErrorHierarchy::is_member_id_required_error(self)
4370    }
4371
4372    /// Returns whether this error's Java class is, or extends,
4373    /// `org.apache.kafka.common.errors.MismatchedEndpointTypeException`.
4374    ///
4375    /// Prefer this to matching [`Error::MismatchedEndpointType`](Self::MismatchedEndpointType): a
4376    /// variant match misses the subclasses a later Java release may add.
4377    pub fn is_mismatched_endpoint_type_error(&self) -> bool {
4378        ErrorHierarchy::is_mismatched_endpoint_type_error(self)
4379    }
4380
4381    /// Returns whether this error's Java class is, or extends,
4382    /// `org.apache.kafka.common.errors.NetworkException`.
4383    ///
4384    /// Prefer this to matching [`Error::Network`](Self::Network): a variant match misses the
4385    /// subclasses a later Java release may add.
4386    pub fn is_network_error(&self) -> bool {
4387        ErrorHierarchy::is_network_error(self)
4388    }
4389
4390    /// Returns whether this error's Java class is, or extends,
4391    /// `org.apache.kafka.common.errors.NewLeaderElectedException`.
4392    ///
4393    /// Prefer this to matching [`Error::NewLeaderElected`](Self::NewLeaderElected): a variant match
4394    /// misses the subclasses a later Java release may add.
4395    pub fn is_new_leader_elected_error(&self) -> bool {
4396        ErrorHierarchy::is_new_leader_elected_error(self)
4397    }
4398
4399    /// Returns whether this error's Java class is, or extends,
4400    /// `org.apache.kafka.common.errors.NoReassignmentInProgressException`.
4401    ///
4402    /// Prefer this to matching [`Error::NoReassignmentInProgress`](Self::NoReassignmentInProgress):
4403    /// a variant match misses the subclasses a later Java release may add.
4404    pub fn is_no_reassignment_in_progress_error(&self) -> bool {
4405        ErrorHierarchy::is_no_reassignment_in_progress_error(self)
4406    }
4407
4408    /// Returns whether this error's Java class is, or extends,
4409    /// `org.apache.kafka.common.errors.NotControllerException`.
4410    ///
4411    /// Prefer this to matching [`Error::NotController`](Self::NotController): a variant match
4412    /// misses the subclasses a later Java release may add.
4413    pub fn is_not_controller_error(&self) -> bool {
4414        ErrorHierarchy::is_not_controller_error(self)
4415    }
4416
4417    /// Returns whether this error's Java class is, or extends,
4418    /// `org.apache.kafka.common.errors.NotCoordinatorException`.
4419    ///
4420    /// Prefer this to matching [`Error::NotCoordinator`](Self::NotCoordinator): a variant match
4421    /// misses the subclasses a later Java release may add.
4422    pub fn is_not_coordinator_error(&self) -> bool {
4423        ErrorHierarchy::is_not_coordinator_error(self)
4424    }
4425
4426    /// Returns whether this error's Java class is, or extends,
4427    /// `org.apache.kafka.common.errors.NotEnoughReplicasException`.
4428    ///
4429    /// Prefer this to matching [`Error::NotEnoughReplicas`](Self::NotEnoughReplicas): a variant
4430    /// match misses the subclasses a later Java release may add.
4431    pub fn is_not_enough_replicas_error(&self) -> bool {
4432        ErrorHierarchy::is_not_enough_replicas_error(self)
4433    }
4434
4435    /// Returns whether this error's Java class is, or extends,
4436    /// `org.apache.kafka.common.errors.NotEnoughReplicasAfterAppendException`.
4437    ///
4438    /// Prefer this to matching
4439    /// [`Error::NotEnoughReplicasAfterAppend`](Self::NotEnoughReplicasAfterAppend): a variant match
4440    /// misses the subclasses a later Java release may add.
4441    pub fn is_not_enough_replicas_after_append_error(&self) -> bool {
4442        ErrorHierarchy::is_not_enough_replicas_after_append_error(self)
4443    }
4444
4445    /// Returns whether this error's Java class is, or extends,
4446    /// `org.apache.kafka.common.errors.NotLeaderOrFollowerException`.
4447    ///
4448    /// Prefer this to matching [`Error::NotLeaderOrFollower`](Self::NotLeaderOrFollower): a variant
4449    /// match misses the subclasses a later Java release may add.
4450    pub fn is_not_leader_or_follower_error(&self) -> bool {
4451        ErrorHierarchy::is_not_leader_or_follower_error(self)
4452    }
4453
4454    /// Returns whether this error's Java class is, or extends,
4455    /// `org.apache.kafka.common.errors.OffsetMetadataTooLarge`.
4456    ///
4457    /// Prefer this to matching [`Error::OffsetMetadataTooLarge`](Self::OffsetMetadataTooLarge): a
4458    /// variant match misses the subclasses a later Java release may add.
4459    pub fn is_offset_metadata_too_large_error(&self) -> bool {
4460        ErrorHierarchy::is_offset_metadata_too_large_error(self)
4461    }
4462
4463    /// Returns whether this error's Java class is, or extends,
4464    /// `org.apache.kafka.common.errors.OffsetMovedToTieredStorageException`.
4465    ///
4466    /// Prefer this to matching
4467    /// [`Error::OffsetMovedToTieredStorage`](Self::OffsetMovedToTieredStorage): a variant match
4468    /// misses the subclasses a later Java release may add.
4469    pub fn is_offset_moved_to_tiered_storage_error(&self) -> bool {
4470        ErrorHierarchy::is_offset_moved_to_tiered_storage_error(self)
4471    }
4472
4473    /// Returns whether this error's Java class is, or extends,
4474    /// `org.apache.kafka.common.errors.OffsetNotAvailableException`.
4475    ///
4476    /// Prefer this to matching [`Error::OffsetNotAvailable`](Self::OffsetNotAvailable): a variant
4477    /// match misses the subclasses a later Java release may add.
4478    pub fn is_offset_not_available_error(&self) -> bool {
4479        ErrorHierarchy::is_offset_not_available_error(self)
4480    }
4481
4482    /// Returns whether this error's Java class is, or extends,
4483    /// `org.apache.kafka.common.errors.OffsetOutOfRangeException`.
4484    ///
4485    /// Prefer this to matching [`Error::OffsetOutOfRange`](Self::OffsetOutOfRange): a variant match
4486    /// misses the subclasses a later Java release may add.
4487    pub fn is_offset_out_of_range_error(&self) -> bool {
4488        ErrorHierarchy::is_offset_out_of_range_error(self)
4489    }
4490
4491    /// Returns whether this error's Java class is, or extends,
4492    /// `org.apache.kafka.common.errors.OperationNotAttemptedException`.
4493    ///
4494    /// Prefer this to matching [`Error::OperationNotAttempted`](Self::OperationNotAttempted): a
4495    /// variant match misses the subclasses a later Java release may add.
4496    pub fn is_operation_not_attempted_error(&self) -> bool {
4497        ErrorHierarchy::is_operation_not_attempted_error(self)
4498    }
4499
4500    /// Returns whether this error's Java class is, or extends,
4501    /// `org.apache.kafka.common.errors.PolicyViolationException`.
4502    ///
4503    /// Prefer this to matching [`Error::PolicyViolation`](Self::PolicyViolation): a variant match
4504    /// misses the subclasses a later Java release may add.
4505    pub fn is_policy_violation_error(&self) -> bool {
4506        ErrorHierarchy::is_policy_violation_error(self)
4507    }
4508
4509    /// Returns whether this error's Java class is, or extends,
4510    /// `org.apache.kafka.common.errors.PositionOutOfRangeException`.
4511    ///
4512    /// Prefer this to matching [`Error::PositionOutOfRange`](Self::PositionOutOfRange): a variant
4513    /// match misses the subclasses a later Java release may add.
4514    pub fn is_position_out_of_range_error(&self) -> bool {
4515        ErrorHierarchy::is_position_out_of_range_error(self)
4516    }
4517
4518    /// Returns whether this error's Java class is, or extends,
4519    /// `org.apache.kafka.common.errors.PreferredLeaderNotAvailableException`.
4520    ///
4521    /// Prefer this to matching
4522    /// [`Error::PreferredLeaderNotAvailable`](Self::PreferredLeaderNotAvailable): a variant match
4523    /// misses the subclasses a later Java release may add.
4524    pub fn is_preferred_leader_not_available_error(&self) -> bool {
4525        ErrorHierarchy::is_preferred_leader_not_available_error(self)
4526    }
4527
4528    /// Returns whether this error's Java class is, or extends,
4529    /// `org.apache.kafka.common.errors.PrincipalDeserializationException`.
4530    ///
4531    /// Prefer this to matching [`Error::PrincipalDeserialization`](Self::PrincipalDeserialization):
4532    /// a variant match misses the subclasses a later Java release may add.
4533    pub fn is_principal_deserialization_error(&self) -> bool {
4534        ErrorHierarchy::is_principal_deserialization_error(self)
4535    }
4536
4537    /// Returns whether this error's Java class is, or extends,
4538    /// `org.apache.kafka.common.errors.ProducerFencedException`.
4539    ///
4540    /// Prefer this to matching [`Error::ProducerFenced`](Self::ProducerFenced): a variant match
4541    /// misses the subclasses a later Java release may add.
4542    pub fn is_producer_fenced_error(&self) -> bool {
4543        ErrorHierarchy::is_producer_fenced_error(self)
4544    }
4545
4546    /// Returns whether this error's Java class is, or extends,
4547    /// `org.apache.kafka.common.metrics.QuotaViolationException`.
4548    ///
4549    /// Prefer this to matching [`Error::QuotaViolation`](Self::QuotaViolation): a variant match
4550    /// misses the subclasses a later Java release may add.
4551    pub fn is_quota_violation_error(&self) -> bool {
4552        ErrorHierarchy::is_quota_violation_error(self)
4553    }
4554
4555    /// Returns whether this error's Java class is, or extends,
4556    /// `org.apache.kafka.common.errors.ReassignmentInProgressException`.
4557    ///
4558    /// Prefer this to matching [`Error::ReassignmentInProgress`](Self::ReassignmentInProgress): a
4559    /// variant match misses the subclasses a later Java release may add.
4560    pub fn is_reassignment_in_progress_error(&self) -> bool {
4561        ErrorHierarchy::is_reassignment_in_progress_error(self)
4562    }
4563
4564    /// Returns whether this error's Java class is, or extends,
4565    /// `org.apache.kafka.common.errors.RebalanceInProgressException`.
4566    ///
4567    /// Prefer this to matching [`Error::RebalanceInProgress`](Self::RebalanceInProgress): a variant
4568    /// match misses the subclasses a later Java release may add.
4569    pub fn is_rebalance_in_progress_error(&self) -> bool {
4570        ErrorHierarchy::is_rebalance_in_progress_error(self)
4571    }
4572
4573    /// Returns whether this error's Java class is, or extends,
4574    /// `org.apache.kafka.common.errors.RebootstrapRequiredException`.
4575    ///
4576    /// Prefer this to matching [`Error::RebootstrapRequired`](Self::RebootstrapRequired): a variant
4577    /// match misses the subclasses a later Java release may add.
4578    pub fn is_rebootstrap_required_error(&self) -> bool {
4579        ErrorHierarchy::is_rebootstrap_required_error(self)
4580    }
4581
4582    /// Returns whether this error's Java class is, or extends,
4583    /// `org.apache.kafka.common.errors.RecordBatchTooLargeException`.
4584    ///
4585    /// Prefer this to matching [`Error::RecordBatchTooLarge`](Self::RecordBatchTooLarge): a variant
4586    /// match misses the subclasses a later Java release may add.
4587    pub fn is_record_batch_too_large_error(&self) -> bool {
4588        ErrorHierarchy::is_record_batch_too_large_error(self)
4589    }
4590
4591    /// Returns whether this error's Java class is, or extends,
4592    /// `org.apache.kafka.common.errors.RecordDeserializationException`.
4593    ///
4594    /// Prefer this to matching [`Error::RecordDeserialization`](Self::RecordDeserialization): a
4595    /// variant match misses the subclasses a later Java release may add.
4596    pub fn is_record_deserialization_error(&self) -> bool {
4597        ErrorHierarchy::is_record_deserialization_error(self)
4598    }
4599
4600    /// Returns whether this error's Java class is, or extends,
4601    /// `org.apache.kafka.common.errors.RecordTooLargeException`.
4602    ///
4603    /// Prefer this to matching [`Error::RecordTooLarge`](Self::RecordTooLarge): a variant match
4604    /// misses the subclasses a later Java release may add.
4605    pub fn is_record_too_large_error(&self) -> bool {
4606        ErrorHierarchy::is_record_too_large_error(self)
4607    }
4608
4609    /// Returns whether this error's Java class is, or extends,
4610    /// `org.apache.kafka.common.network.InvalidReceiveException`.
4611    ///
4612    /// Prefer this to matching [`Error::InvalidReceive`](Self::InvalidReceive): a variant match
4613    /// misses the subclasses a later Java release may add.
4614    pub fn is_invalid_receive_error(&self) -> bool {
4615        ErrorHierarchy::is_invalid_receive_error(self)
4616    }
4617
4618    /// Returns whether this error's Java class is, or extends,
4619    /// `org.apache.kafka.common.config.ConfigException`.
4620    ///
4621    /// Prefer this to matching [`Error::Config`](Self::Config): a variant match misses the
4622    /// subclasses a later Java release may add.
4623    pub fn is_config_error(&self) -> bool {
4624        ErrorHierarchy::is_config_error(self)
4625    }
4626
4627    /// Returns whether this error's Java class is, or extends,
4628    /// `org.apache.kafka.clients.consumer.RetriableCommitFailedException`.
4629    ///
4630    /// Prefer this to matching
4631    /// [`Error::ConsumerRetriableCommitFailed`](Self::ConsumerRetriableCommitFailed): a variant
4632    /// match misses the subclasses a later Java release may add.
4633    pub fn is_consumer_retriable_commit_failed_error(&self) -> bool {
4634        ErrorHierarchy::is_consumer_retriable_commit_failed_error(self)
4635    }
4636
4637    /// Returns whether this error's Java class is, or extends,
4638    /// `org.apache.kafka.clients.consumer.CommitFailedException`.
4639    ///
4640    /// Prefer this to matching [`Error::ConsumerCommitFailed`](Self::ConsumerCommitFailed): a
4641    /// variant match misses the subclasses a later Java release may add.
4642    pub fn is_consumer_commit_failed_error(&self) -> bool {
4643        ErrorHierarchy::is_consumer_commit_failed_error(self)
4644    }
4645
4646    /// Returns whether this error's Java class is, or extends,
4647    /// `org.apache.kafka.clients.consumer.NoOffsetForPartitionException`.
4648    ///
4649    /// Prefer this to matching
4650    /// [`Error::ConsumerNoOffsetForPartition`](Self::ConsumerNoOffsetForPartition): a variant match
4651    /// misses the subclasses a later Java release may add.
4652    pub fn is_consumer_no_offset_for_partition_error(&self) -> bool {
4653        ErrorHierarchy::is_consumer_no_offset_for_partition_error(self)
4654    }
4655
4656    /// Returns whether this error's Java class is, or extends,
4657    /// `org.apache.kafka.clients.consumer.LogTruncationException`.
4658    ///
4659    /// Prefer this to matching [`Error::ConsumerLogTruncation`](Self::ConsumerLogTruncation): a
4660    /// variant match misses the subclasses a later Java release may add.
4661    pub fn is_consumer_log_truncation_error(&self) -> bool {
4662        ErrorHierarchy::is_consumer_log_truncation_error(self)
4663    }
4664
4665    /// Returns whether this error's Java class is, or extends,
4666    /// `org.apache.kafka.common.errors.ReplicaNotAvailableException`.
4667    ///
4668    /// Prefer this to matching [`Error::ReplicaNotAvailable`](Self::ReplicaNotAvailable): a variant
4669    /// match misses the subclasses a later Java release may add.
4670    pub fn is_replica_not_available_error(&self) -> bool {
4671        ErrorHierarchy::is_replica_not_available_error(self)
4672    }
4673
4674    /// Returns whether this error's Java class is, or extends,
4675    /// `org.apache.kafka.common.errors.ResourceNotFoundException`.
4676    ///
4677    /// Prefer this to matching [`Error::ResourceNotFound`](Self::ResourceNotFound): a variant match
4678    /// misses the subclasses a later Java release may add.
4679    pub fn is_resource_not_found_error(&self) -> bool {
4680        ErrorHierarchy::is_resource_not_found_error(self)
4681    }
4682
4683    /// Returns whether this error's Java class is, or extends,
4684    /// `org.apache.kafka.common.errors.SaslAuthenticationException`.
4685    ///
4686    /// Prefer this to matching [`Error::SaslAuthentication`](Self::SaslAuthentication): a variant
4687    /// match misses the subclasses a later Java release may add.
4688    pub fn is_sasl_authentication_error(&self) -> bool {
4689        ErrorHierarchy::is_sasl_authentication_error(self)
4690    }
4691
4692    /// Returns whether this error's Java class is, or extends,
4693    /// `org.apache.kafka.common.protocol.types.SchemaException`.
4694    ///
4695    /// Prefer this to matching [`Error::Schema`](Self::Schema): a variant match misses the
4696    /// subclasses a later Java release may add.
4697    pub fn is_schema_error(&self) -> bool {
4698        ErrorHierarchy::is_schema_error(self)
4699    }
4700
4701    /// Returns whether this error's Java class is, or extends,
4702    /// `org.apache.kafka.common.errors.SecurityDisabledException`.
4703    ///
4704    /// Prefer this to matching [`Error::SecurityDisabled`](Self::SecurityDisabled): a variant match
4705    /// misses the subclasses a later Java release may add.
4706    pub fn is_security_disabled_error(&self) -> bool {
4707        ErrorHierarchy::is_security_disabled_error(self)
4708    }
4709
4710    /// Returns whether this error's Java class is, or extends,
4711    /// `org.apache.kafka.common.errors.ShareSessionLimitReachedException`.
4712    ///
4713    /// Prefer this to matching [`Error::ShareSessionLimitReached`](Self::ShareSessionLimitReached):
4714    /// a variant match misses the subclasses a later Java release may add.
4715    pub fn is_share_session_limit_reached_error(&self) -> bool {
4716        ErrorHierarchy::is_share_session_limit_reached_error(self)
4717    }
4718
4719    /// Returns whether this error's Java class is, or extends,
4720    /// `org.apache.kafka.common.errors.ShareSessionNotFoundException`.
4721    ///
4722    /// Prefer this to matching [`Error::ShareSessionNotFound`](Self::ShareSessionNotFound): a
4723    /// variant match misses the subclasses a later Java release may add.
4724    pub fn is_share_session_not_found_error(&self) -> bool {
4725        ErrorHierarchy::is_share_session_not_found_error(self)
4726    }
4727
4728    /// Returns whether this error's Java class is, or extends,
4729    /// `org.apache.kafka.common.errors.SnapshotNotFoundException`.
4730    ///
4731    /// Prefer this to matching [`Error::SnapshotNotFound`](Self::SnapshotNotFound): a variant match
4732    /// misses the subclasses a later Java release may add.
4733    pub fn is_snapshot_not_found_error(&self) -> bool {
4734        ErrorHierarchy::is_snapshot_not_found_error(self)
4735    }
4736
4737    /// Returns whether this error's Java class is, or extends,
4738    /// `org.apache.kafka.common.errors.SslAuthenticationException`.
4739    ///
4740    /// Prefer this to matching [`Error::SslAuthentication`](Self::SslAuthentication): a variant
4741    /// match misses the subclasses a later Java release may add.
4742    pub fn is_ssl_authentication_error(&self) -> bool {
4743        ErrorHierarchy::is_ssl_authentication_error(self)
4744    }
4745
4746    /// Returns whether this error's Java class is, or extends,
4747    /// `org.apache.kafka.common.errors.StaleBrokerEpochException`.
4748    ///
4749    /// Prefer this to matching [`Error::StaleBrokerEpoch`](Self::StaleBrokerEpoch): a variant match
4750    /// misses the subclasses a later Java release may add.
4751    pub fn is_stale_broker_epoch_error(&self) -> bool {
4752        ErrorHierarchy::is_stale_broker_epoch_error(self)
4753    }
4754
4755    /// Returns whether this error's Java class is, or extends,
4756    /// `org.apache.kafka.common.errors.StaleMemberEpochException`.
4757    ///
4758    /// Prefer this to matching [`Error::StaleMemberEpoch`](Self::StaleMemberEpoch): a variant match
4759    /// misses the subclasses a later Java release may add.
4760    pub fn is_stale_member_epoch_error(&self) -> bool {
4761        ErrorHierarchy::is_stale_member_epoch_error(self)
4762    }
4763
4764    /// Returns whether this error's Java class is, or extends,
4765    /// `org.apache.kafka.common.errors.StreamsInvalidTopologyException`.
4766    ///
4767    /// Prefer this to matching [`Error::StreamsInvalidTopology`](Self::StreamsInvalidTopology): a
4768    /// variant match misses the subclasses a later Java release may add.
4769    pub fn is_streams_invalid_topology_error(&self) -> bool {
4770        ErrorHierarchy::is_streams_invalid_topology_error(self)
4771    }
4772
4773    /// Returns whether this error's Java class is, or extends,
4774    /// `org.apache.kafka.common.errors.StreamsInvalidTopologyEpochException`.
4775    ///
4776    /// Prefer this to matching
4777    /// [`Error::StreamsInvalidTopologyEpoch`](Self::StreamsInvalidTopologyEpoch): a variant match
4778    /// misses the subclasses a later Java release may add.
4779    pub fn is_streams_invalid_topology_epoch_error(&self) -> bool {
4780        ErrorHierarchy::is_streams_invalid_topology_epoch_error(self)
4781    }
4782
4783    /// Returns whether this error's Java class is, or extends,
4784    /// `org.apache.kafka.common.errors.StreamsTopologyDescriptionUpdateFailedException`.
4785    ///
4786    /// Prefer this to matching [`Error::StreamsTopologyDescriptionUpdateFailed`](Self::StreamsTopologyDescriptionUpdateFailed): a variant
4787    /// match misses the subclasses a later Java release may add.
4788    pub fn is_streams_topology_description_update_failed_error(&self) -> bool {
4789        ErrorHierarchy::is_streams_topology_description_update_failed_error(self)
4790    }
4791
4792    /// Returns whether this error's Java class is, or extends,
4793    /// `org.apache.kafka.common.errors.StreamsTopologyFencedException`.
4794    ///
4795    /// Prefer this to matching [`Error::StreamsTopologyFenced`](Self::StreamsTopologyFenced): a
4796    /// variant match misses the subclasses a later Java release may add.
4797    pub fn is_streams_topology_fenced_error(&self) -> bool {
4798        ErrorHierarchy::is_streams_topology_fenced_error(self)
4799    }
4800
4801    /// Returns whether this error's Java class is, or extends,
4802    /// `org.apache.kafka.common.errors.TelemetryTooLargeException`.
4803    ///
4804    /// Prefer this to matching [`Error::TelemetryTooLarge`](Self::TelemetryTooLarge): a variant
4805    /// match misses the subclasses a later Java release may add.
4806    pub fn is_telemetry_too_large_error(&self) -> bool {
4807        ErrorHierarchy::is_telemetry_too_large_error(self)
4808    }
4809
4810    /// Returns whether this error's Java class is, or extends,
4811    /// `org.apache.kafka.common.errors.ThrottlingQuotaExceededException`.
4812    ///
4813    /// Prefer this to matching [`Error::ThrottlingQuotaExceeded`](Self::ThrottlingQuotaExceeded): a
4814    /// variant match misses the subclasses a later Java release may add.
4815    pub fn is_throttling_quota_exceeded_error(&self) -> bool {
4816        ErrorHierarchy::is_throttling_quota_exceeded_error(self)
4817    }
4818
4819    /// Returns whether this error's Java class is, or extends,
4820    /// `org.apache.kafka.common.errors.TopicAuthorizationException`.
4821    ///
4822    /// Prefer this to matching [`Error::TopicAuthorization`](Self::TopicAuthorization): a variant
4823    /// match misses the subclasses a later Java release may add.
4824    pub fn is_topic_authorization_error(&self) -> bool {
4825        ErrorHierarchy::is_topic_authorization_error(self)
4826    }
4827
4828    /// Returns whether this error's Java class is, or extends,
4829    /// `org.apache.kafka.common.errors.TopicDeletionDisabledException`.
4830    ///
4831    /// Prefer this to matching [`Error::TopicDeletionDisabled`](Self::TopicDeletionDisabled): a
4832    /// variant match misses the subclasses a later Java release may add.
4833    pub fn is_topic_deletion_disabled_error(&self) -> bool {
4834        ErrorHierarchy::is_topic_deletion_disabled_error(self)
4835    }
4836
4837    /// Returns whether this error's Java class is, or extends,
4838    /// `org.apache.kafka.common.errors.TopicExistsException`.
4839    ///
4840    /// Prefer this to matching [`Error::TopicExists`](Self::TopicExists): a variant match misses
4841    /// the subclasses a later Java release may add.
4842    pub fn is_topic_exists_error(&self) -> bool {
4843        ErrorHierarchy::is_topic_exists_error(self)
4844    }
4845
4846    /// Returns whether this error's Java class is, or extends,
4847    /// `org.apache.kafka.common.errors.TransactionAbortableException`.
4848    ///
4849    /// Prefer this to matching [`Error::TransactionAbortable`](Self::TransactionAbortable): a
4850    /// variant match misses the subclasses a later Java release may add.
4851    ///
4852    /// Java tests this class in two ways: by code (`error == Errors.TRANSACTION_ABORTABLE`,
4853    /// four sites in `TransactionManager`) and by class
4854    /// (`error.exception() instanceof TransactionAbortableException`,
4855    /// in `TransactionManager`). This predicate is the class test.
4856    pub fn is_transaction_abortable_error(&self) -> bool {
4857        ErrorHierarchy::is_transaction_abortable_error(self)
4858    }
4859
4860    /// Returns whether this error's Java class is, or extends,
4861    /// `org.apache.kafka.common.errors.TransactionAbortedException`.
4862    ///
4863    /// Prefer this to matching [`Error::TransactionAborted`](Self::TransactionAborted): a variant
4864    /// match misses the subclasses a later Java release may add.
4865    pub fn is_transaction_aborted_error(&self) -> bool {
4866        ErrorHierarchy::is_transaction_aborted_error(self)
4867    }
4868
4869    /// Returns whether this error's Java class is, or extends,
4870    /// `org.apache.kafka.common.errors.TransactionCoordinatorFencedException`.
4871    ///
4872    /// Prefer this to matching
4873    /// [`Error::TransactionCoordinatorFenced`](Self::TransactionCoordinatorFenced): a variant match
4874    /// misses the subclasses a later Java release may add.
4875    pub fn is_transaction_coordinator_fenced_error(&self) -> bool {
4876        ErrorHierarchy::is_transaction_coordinator_fenced_error(self)
4877    }
4878
4879    /// Returns whether this error's Java class is, or extends,
4880    /// `org.apache.kafka.common.errors.TransactionalIdAuthorizationException`.
4881    ///
4882    /// Prefer this to matching
4883    /// [`Error::TransactionalIdAuthorization`](Self::TransactionalIdAuthorization): a variant match
4884    /// misses the subclasses a later Java release may add.
4885    pub fn is_transactional_id_authorization_error(&self) -> bool {
4886        ErrorHierarchy::is_transactional_id_authorization_error(self)
4887    }
4888
4889    /// Returns whether this error's Java class is, or extends,
4890    /// `org.apache.kafka.common.errors.TransactionalIdNotFoundException`.
4891    ///
4892    /// Prefer this to matching [`Error::TransactionalIdNotFound`](Self::TransactionalIdNotFound): a
4893    /// variant match misses the subclasses a later Java release may add.
4894    pub fn is_transactional_id_not_found_error(&self) -> bool {
4895        ErrorHierarchy::is_transactional_id_not_found_error(self)
4896    }
4897
4898    /// Returns whether this error's Java class is, or extends,
4899    /// `org.apache.kafka.common.errors.UnacceptableCredentialException`.
4900    ///
4901    /// Prefer this to matching [`Error::UnacceptableCredential`](Self::UnacceptableCredential): a
4902    /// variant match misses the subclasses a later Java release may add.
4903    pub fn is_unacceptable_credential_error(&self) -> bool {
4904        ErrorHierarchy::is_unacceptable_credential_error(self)
4905    }
4906
4907    /// Returns whether this error's Java class is, or extends,
4908    /// `org.apache.kafka.common.errors.UnknownControllerIdException`.
4909    ///
4910    /// Prefer this to matching [`Error::UnknownControllerId`](Self::UnknownControllerId): a variant
4911    /// match misses the subclasses a later Java release may add.
4912    pub fn is_unknown_controller_id_error(&self) -> bool {
4913        ErrorHierarchy::is_unknown_controller_id_error(self)
4914    }
4915
4916    /// Returns whether this error's Java class is, or extends,
4917    /// `org.apache.kafka.common.errors.UnknownLeaderEpochException`.
4918    ///
4919    /// Prefer this to matching [`Error::UnknownLeaderEpoch`](Self::UnknownLeaderEpoch): a variant
4920    /// match misses the subclasses a later Java release may add.
4921    pub fn is_unknown_leader_epoch_error(&self) -> bool {
4922        ErrorHierarchy::is_unknown_leader_epoch_error(self)
4923    }
4924
4925    /// Returns whether this error's Java class is, or extends,
4926    /// `org.apache.kafka.common.errors.UnknownMemberIdException`.
4927    ///
4928    /// Prefer this to matching [`Error::UnknownMemberId`](Self::UnknownMemberId): a variant match
4929    /// misses the subclasses a later Java release may add.
4930    pub fn is_unknown_member_id_error(&self) -> bool {
4931        ErrorHierarchy::is_unknown_member_id_error(self)
4932    }
4933
4934    /// Returns whether this error's Java class is, or extends,
4935    /// `org.apache.kafka.common.errors.UnknownProducerIdException`.
4936    ///
4937    /// Prefer this to matching [`Error::UnknownProducerId`](Self::UnknownProducerId): a variant
4938    /// match misses the subclasses a later Java release may add.
4939    pub fn is_unknown_producer_id_error(&self) -> bool {
4940        ErrorHierarchy::is_unknown_producer_id_error(self)
4941    }
4942
4943    /// Returns whether this error's Java class is, or extends,
4944    /// `org.apache.kafka.common.errors.UnknownServerException`.
4945    ///
4946    /// Prefer this to matching [`Error::UnknownServer`](Self::UnknownServer): a variant match
4947    /// misses the subclasses a later Java release may add.
4948    pub fn is_unknown_server_error(&self) -> bool {
4949        ErrorHierarchy::is_unknown_server_error(self)
4950    }
4951
4952    /// Returns whether this error's Java class is, or extends,
4953    /// `org.apache.kafka.common.errors.UnknownSubscriptionIdException`.
4954    ///
4955    /// Prefer this to matching [`Error::UnknownSubscriptionId`](Self::UnknownSubscriptionId): a
4956    /// variant match misses the subclasses a later Java release may add.
4957    pub fn is_unknown_subscription_id_error(&self) -> bool {
4958        ErrorHierarchy::is_unknown_subscription_id_error(self)
4959    }
4960
4961    /// Returns whether this error's Java class is, or extends,
4962    /// `org.apache.kafka.common.errors.UnknownTopicIdException`.
4963    ///
4964    /// Prefer this to matching [`Error::UnknownTopicId`](Self::UnknownTopicId): a variant match
4965    /// misses the subclasses a later Java release may add.
4966    pub fn is_unknown_topic_id_error(&self) -> bool {
4967        ErrorHierarchy::is_unknown_topic_id_error(self)
4968    }
4969
4970    /// Returns whether this error's Java class is, or extends,
4971    /// `org.apache.kafka.common.errors.UnknownTopicOrPartitionException`.
4972    ///
4973    /// Prefer this to matching [`Error::UnknownTopicOrPartition`](Self::UnknownTopicOrPartition): a
4974    /// variant match misses the subclasses a later Java release may add.
4975    pub fn is_unknown_topic_or_partition_error(&self) -> bool {
4976        ErrorHierarchy::is_unknown_topic_or_partition_error(self)
4977    }
4978
4979    /// Returns whether this error's Java class is, or extends,
4980    /// `org.apache.kafka.common.errors.UnreleasedInstanceIdException`.
4981    ///
4982    /// Prefer this to matching [`Error::UnreleasedInstanceId`](Self::UnreleasedInstanceId): a
4983    /// variant match misses the subclasses a later Java release may add.
4984    pub fn is_unreleased_instance_id_error(&self) -> bool {
4985        ErrorHierarchy::is_unreleased_instance_id_error(self)
4986    }
4987
4988    /// Returns whether this error's Java class is, or extends,
4989    /// `org.apache.kafka.common.errors.UnstableOffsetCommitException`.
4990    ///
4991    /// Prefer this to matching [`Error::UnstableOffsetCommit`](Self::UnstableOffsetCommit): a
4992    /// variant match misses the subclasses a later Java release may add.
4993    pub fn is_unstable_offset_commit_error(&self) -> bool {
4994        ErrorHierarchy::is_unstable_offset_commit_error(self)
4995    }
4996
4997    /// Returns whether this error's Java class is, or extends,
4998    /// `org.apache.kafka.common.errors.UnsupportedAssignorException`.
4999    ///
5000    /// Prefer this to matching [`Error::UnsupportedAssignor`](Self::UnsupportedAssignor): a variant
5001    /// match misses the subclasses a later Java release may add.
5002    pub fn is_unsupported_assignor_error(&self) -> bool {
5003        ErrorHierarchy::is_unsupported_assignor_error(self)
5004    }
5005
5006    /// Returns whether this error's Java class is, or extends,
5007    /// `org.apache.kafka.common.errors.UnsupportedByAuthenticationException`.
5008    ///
5009    /// Prefer this to matching
5010    /// [`Error::UnsupportedByAuthentication`](Self::UnsupportedByAuthentication): a variant match
5011    /// misses the subclasses a later Java release may add.
5012    pub fn is_unsupported_by_authentication_error(&self) -> bool {
5013        ErrorHierarchy::is_unsupported_by_authentication_error(self)
5014    }
5015
5016    /// Returns whether this error's Java class is, or extends,
5017    /// `org.apache.kafka.common.errors.UnsupportedCompressionTypeException`.
5018    ///
5019    /// Prefer this to matching
5020    /// [`Error::UnsupportedCompressionType`](Self::UnsupportedCompressionType): a variant match
5021    /// misses the subclasses a later Java release may add.
5022    pub fn is_unsupported_compression_type_error(&self) -> bool {
5023        ErrorHierarchy::is_unsupported_compression_type_error(self)
5024    }
5025
5026    /// Returns whether this error's Java class is, or extends,
5027    /// `org.apache.kafka.common.errors.UnsupportedEndpointTypeException`.
5028    ///
5029    /// Prefer this to matching [`Error::UnsupportedEndpointType`](Self::UnsupportedEndpointType): a
5030    /// variant match misses the subclasses a later Java release may add.
5031    pub fn is_unsupported_endpoint_type_error(&self) -> bool {
5032        ErrorHierarchy::is_unsupported_endpoint_type_error(self)
5033    }
5034
5035    /// Returns whether this error's Java class is, or extends,
5036    /// `org.apache.kafka.common.errors.UnsupportedForMessageFormatException`.
5037    ///
5038    /// Prefer this to matching
5039    /// [`Error::UnsupportedForMessageFormat`](Self::UnsupportedForMessageFormat): a variant match
5040    /// misses the subclasses a later Java release may add.
5041    pub fn is_unsupported_for_message_format_error(&self) -> bool {
5042        ErrorHierarchy::is_unsupported_for_message_format_error(self)
5043    }
5044
5045    /// Returns whether this error's Java class is, or extends,
5046    /// `org.apache.kafka.common.errors.UnsupportedSaslMechanismException`.
5047    ///
5048    /// Prefer this to matching [`Error::UnsupportedSaslMechanism`](Self::UnsupportedSaslMechanism):
5049    /// a variant match misses the subclasses a later Java release may add.
5050    pub fn is_unsupported_sasl_mechanism_error(&self) -> bool {
5051        ErrorHierarchy::is_unsupported_sasl_mechanism_error(self)
5052    }
5053
5054    /// Returns whether this error's Java class extends `UnsupportedVersionException`.
5055    ///
5056    /// Exactly the [`UnsupportedVersion`](Self::UnsupportedVersion) variant
5057    /// (`Errors::UnsupportedVersion`). Java's subclasses —
5058    /// `UnsupportedProtocolFieldException` (Kafka 4.4, KAFKA-18157) and the
5059    /// `NoBatchedFindCoordinatorsException` / `NoBatchedOffsetFetchRequestException`
5060    /// nested in `FindCoordinatorRequest` / `OffsetFetchRequest` — are none of
5061    /// them public, so they are carried inside that variant rather than as
5062    /// variants of their own; this predicate therefore answers `true` for them
5063    /// too, as Java's `instanceof UnsupportedVersionException` does.
5064    ///
5065    /// Nested inside [`is_invalid_configuration_error`](Self::is_invalid_configuration_error),
5066    /// because `UnsupportedVersionException extends InvalidConfigurationException`.
5067    /// The set is pinned in both directions over every code by `errors.rs`'s
5068    /// `test_hierarchy_predicates_match_java`.
5069    ///
5070    /// Prefer this to matching [`Error::UnsupportedVersion`](Self::UnsupportedVersion): a variant
5071    /// match misses the subclasses a later Java release may add.
5072    pub fn is_unsupported_version_error(&self) -> bool {
5073        ErrorHierarchy::is_unsupported_version_error(self)
5074    }
5075
5076    /// Returns whether this error's Java class is, or extends,
5077    /// `org.apache.kafka.common.errors.VoterNotFoundException`.
5078    ///
5079    /// Prefer this to matching [`Error::VoterNotFound`](Self::VoterNotFound): a variant match
5080    /// misses the subclasses a later Java release may add.
5081    pub fn is_voter_not_found_error(&self) -> bool {
5082        ErrorHierarchy::is_voter_not_found_error(self)
5083    }
5084
5085    /// Returns whether this error's Java class is, or extends,
5086    /// `org.apache.kafka.common.errors.WakeupException`.
5087    ///
5088    /// Prefer this to matching [`Error::Wakeup`](Self::Wakeup): a variant match misses the
5089    /// subclasses a later Java release may add.
5090    pub fn is_wakeup_error(&self) -> bool {
5091        ErrorHierarchy::is_wakeup_error(self)
5092    }
5093}
5094
5095// `impl Display for Error` is generated by `#[delegate(Display)]` on the enum:
5096// each variant forwards to its payload's own `Display`, which renders the way
5097// that payload's Java class implements `toString()`.
5098
5099impl std::error::Error for Error {
5100    // The standard-library view of Java's `Throwable.getCause()`, so
5101    // `{:#}`-style reporters and `anyhow`-style chains walk the cause chain.
5102    fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
5103        // UFCS: `self.source()` would resolve to the inherent method below.
5104        ErrorSource::source(self).map(|e| e as &(dyn std::error::Error + 'static))
5105    }
5106}
5107
5108#[cfg(test)]
5109mod tests {
5110    use super::*;
5111
5112    /// Java's `getCause()` is declared on `Throwable`, so every error answers it;
5113    /// the Rust-side name follows the std trait (`source`). `None` is the common
5114    /// case (Java's null default); a source set through a constructor is readable
5115    /// back, and `std::error::Error::source()` agrees with the inherent accessor.
5116    ///
5117    /// The inherent `source()` shadows both `ErrorSource::source` and
5118    /// `std::error::Error::source`, so `e.source()` is unambiguous and returns the
5119    /// **typed** `Option<&Error>`; the `dyn` view is reachable through the trait
5120    /// and downcasts back to `Error`.
5121    #[test]
5122    fn source_is_universal_and_readable() {
5123        use std::error::Error as StdError;
5124
5125        // Default: no cause, on both a macro-declared class and the base.
5126        assert!(Error::new(Errors::RequestTimedOut).source().is_none());
5127        assert!(Error::local_illegal_state("misuse").source().is_none());
5128        assert!(StdError::source(&Error::new(Errors::RequestTimedOut)).is_none());
5129
5130        // Set through `KafkaError`'s Java-shaped `(String, Throwable)` constructor.
5131        let root = Error::new(Errors::ClusterAuthorizationFailed);
5132        let wrapped = Error::KafkaError(KafkaError::with_message_source(
5133            Errors::UnknownServerError,
5134            "Cannot execute transactional method because we are in an error state",
5135            root,
5136        ));
5137        let source = wrapped.source().expect("the source is retained");
5138        assert_eq!(source.error(), Errors::ClusterAuthorizationFailed);
5139        // The std view agrees, so `source()` chains resolve.
5140        assert!(StdError::source(&wrapped).is_some());
5141        // The wrapper keeps its own code and message.
5142        assert_eq!(wrapped.error(), Errors::UnknownServerError);
5143
5144        // A macro-declared class carries one too (every class has the slot).
5145        let serialization = Error::Serialization(SerializationError::with_source(
5146            "bad bytes",
5147            Error::local_illegal_argument("not utf-8"),
5148        ));
5149        assert_eq!(serialization.source().expect("retained").message(), "not utf-8");
5150
5151        // The chain is walkable to arbitrary depth.
5152        let outer = Error::KafkaError(KafkaError::with_source(Errors::UnknownServerError, serialization));
5153        let mid = outer.source().expect("first link");
5154        assert_eq!(mid.message(), "bad bytes");
5155        assert_eq!(mid.source().expect("second link").message(), "not utf-8");
5156
5157        // The inherent accessor is typed; the std trait's view is `dyn` but
5158        // downcasts straight back to the enum, so nothing is lost either way.
5159        let typed: Option<&Error> = outer.source();
5160        let via_dyn: Option<&Error> = StdError::source(&outer).and_then(|e| e.downcast_ref::<Error>());
5161        assert_eq!(typed.map(Error::message), via_dyn.map(Error::message));
5162        assert!(
5163            matches!(via_dyn, Some(Error::Serialization(_))),
5164            "the concrete variant survives the round-trip"
5165        );
5166
5167        // A `&dyn Error` chain walks the same two levels.
5168        let mut depth = 0;
5169        let mut cursor: Option<&(dyn StdError + 'static)> = StdError::source(&outer);
5170        while let Some(e) = cursor {
5171            depth += 1;
5172            cursor = e.source();
5173        }
5174        assert_eq!(depth, 2, "walking the dyn chain sees both links");
5175
5176        // Classes whose Java counterpart has no `Throwable cause` constructor
5177        // answer `None` — fidelity, not omission.
5178        assert!(
5179            Error::ConsumerCommitFailed(crate::consumer::ConsumerCommitFailedError::with_default_message())
5180                .source()
5181                .is_none()
5182        );
5183    }
5184
5185    /// [`Error::kafka`] must produce a *bare* `KafkaException`, not the
5186    /// `UnknownServerException` that [`Error::with_message`] resolves
5187    /// [`Errors::UnknownServerError`] to.
5188    ///
5189    /// The difference is observable and load-bearing: `KafkaProducer.doSend`
5190    /// dispatches on `catch (ApiException e)` (fire the callback, return a failed
5191    /// future) versus `catch (KafkaException e)` (rethrow), so translating a bare
5192    /// `new KafkaException(..)` through `with_message` silently moves the error into
5193    /// the wrong arm.
5194    #[test]
5195    fn kafka_builds_a_bare_kafka_error_not_an_api_error() {
5196        let bare = Error::kafka_message("Producer closed while send in progress");
5197        assert!(matches!(bare, Error::KafkaError(_)), "got {bare:?}");
5198        assert!(bare.is_kafka_error());
5199        // Java: a bare `KafkaException` is not an `ApiException`.
5200        assert!(!bare.is_api_error(), "a bare Kafka error is not an API error");
5201        assert_eq!(bare.message(), "Producer closed while send in progress");
5202        assert_eq!(bare.error(), Errors::UnknownServerError, "no protocol code of its own");
5203
5204        // The contrast, and why the helper exists.
5205        let resolved = Error::with_message(Errors::UnknownServerError, "same code, different class");
5206        assert!(matches!(resolved, Error::UnknownServer(_)), "got {resolved:?}");
5207        // Java: `UnknownServerException` IS an `ApiException`.
5208        assert!(resolved.is_api_error(), "an unknown-server error IS an API error");
5209
5210        // The `(String, Throwable)` form carries the cause.
5211        let wrapped =
5212            Error::kafka_message_source("Failed to construct kafka producer", Error::config_message("bad ssl path"));
5213        assert!(!wrapped.is_api_error());
5214        assert_eq!(wrapped.message(), "Failed to construct kafka producer");
5215        assert_eq!(wrapped.source().expect("cause retained").message(), "bad ssl path");
5216    }
5217
5218    /// `RetriableCommitFailedException(Throwable)` keeps its cause in Java; the
5219    /// Rust translation used to accept and discard it.
5220    #[test]
5221    fn retriable_commit_failed_retains_its_source() {
5222        let e = Error::ConsumerRetriableCommitFailed(crate::consumer::ConsumerRetriableCommitFailedError::with_source(
5223            Error::timeout("commit timed out"),
5224        ));
5225        assert_eq!(e.source().expect("retained").message(), "commit timed out");
5226    }
5227
5228    /// `LocalConcurrentModification` mirrors `LocalIllegalState`: a plain Java
5229    /// `RuntimeException`, so it carries no protocol code, is never
5230    /// retriable or fatal, and is neither an `ApiException` nor a
5231    /// `KafkaException`.
5232    #[test]
5233    fn concurrent_modification_parity_with_illegal_state() {
5234        let cme = Error::local_concurrent_modification("KafkaConsumer is not safe for multi-threaded access.");
5235        let ise = Error::local_illegal_state("bad state");
5236
5237        assert_eq!(cme.message(), "KafkaConsumer is not safe for multi-threaded access.");
5238        assert_eq!(cme.error().code(), ise.error().code());
5239        assert_eq!(cme.error(), ise.error());
5240        assert_eq!(cme.is_retriable_error(), ise.is_retriable_error());
5241        assert!(!cme.is_retriable_error());
5242        assert_eq!(
5243            crate::common::requests::RequestUtils::is_fatal_error(&cme),
5244            crate::common::requests::RequestUtils::is_fatal_error(&ise)
5245        );
5246        assert!(!crate::common::requests::RequestUtils::is_fatal_error(&cme));
5247        assert_eq!(cme.is_api_error(), ise.is_api_error());
5248        assert!(!cme.is_api_error());
5249        assert_eq!(cme.is_kafka_error(), ise.is_kafka_error());
5250        assert!(!cme.is_kafka_error());
5251        assert!(cme.kafka_error().is_none());
5252    }
5253
5254    /// `LocalUnsupportedOperation` mirrors `LocalIllegalState` too: Java's
5255    /// `UnsupportedOperationException` is a plain `RuntimeException`. It must
5256    /// not be confused with the wire-level `UnsupportedVersionException`, which
5257    /// is an `ApiException` and fatal (`RequestUtils.isFatalException`).
5258    #[test]
5259    fn unsupported_operation_parity_with_illegal_state() {
5260        let uoe = Error::local_unsupported_operation("Not implemented yet");
5261        let ise = Error::local_illegal_state("bad state");
5262
5263        assert_eq!(uoe.message(), "Not implemented yet");
5264        assert_eq!(uoe.to_string(), "LocalUnsupportedOperationError: Not implemented yet");
5265        assert_eq!(uoe.error(), ise.error());
5266        assert!(uoe.is_local_unsupported_operation_error());
5267        assert!(!ise.is_local_unsupported_operation_error());
5268        assert!(!uoe.is_local_illegal_state_error());
5269        assert_eq!(uoe.is_retriable_error(), ise.is_retriable_error());
5270        assert!(!uoe.is_retriable_error());
5271        assert!(!crate::common::requests::RequestUtils::is_fatal_error(&uoe));
5272        assert!(!uoe.is_api_error());
5273        assert!(!uoe.is_kafka_error());
5274        assert!(uoe.kafka_error().is_none());
5275
5276        // The wire-level class it replaces at the `UnsupportedOperationException`
5277        // sites is a different class in both directions.
5278        let version = Error::unsupported_version("Not implemented yet");
5279        assert!(!uoe.is_unsupported_version_error());
5280        assert!(!version.is_local_unsupported_operation_error());
5281        assert!(version.is_api_error());
5282        assert!(crate::common::requests::RequestUtils::is_fatal_error(&version));
5283
5284        // Java's no-argument `new UnsupportedOperationException()`.
5285        let bare = Error::local_unsupported_operation("");
5286        assert_eq!(bare.message(), "");
5287        assert_eq!(bare.to_string(), "LocalUnsupportedOperationError: ");
5288    }
5289
5290    #[test]
5291    fn concurrent_modification_display() {
5292        let cme = Error::local_concurrent_modification("oops");
5293        assert_eq!(cme.to_string(), "LocalConcurrentModificationError: oops");
5294    }
5295
5296    /// Every [`Error`] variant against its Java `extends` chain, in both
5297    /// directions.
5298    ///
5299    /// The predicates are no longer computed by matching on the enum — each is
5300    /// delegated to the variant's payload, whose `impl ErrorHierarchy` declares
5301    /// its ancestry. This table is what stops a payload from silently claiming
5302    /// (or dropping) a superclass, which a per-variant `assert!` could not.
5303    ///
5304    /// Order: kafka, api, retriable, refresh_retriable, timeout,
5305    /// invalid_metadata, invalid_configuration, application_recoverable,
5306    /// invalid_offset, consumer_invalid_offset, consumer_offset_out_of_range,
5307    /// out_of_order_sequence, serialization, authentication, authorization,
5308    /// fatal, unsupported_version — the same order the assertion message below
5309    /// spells out, and the order the `actual` array is built in.
5310    #[test]
5311    fn variant_predicates_match_java_hierarchy() {
5312        use std::collections::HashMap;
5313        let cases: &[(&str, Error, [bool; 17])] = &[
5314            // The three concrete intermediate classes the flattened enum has to
5315            // carry as variants of their own: Java lets a caller `throw new
5316            // ApiException(msg)` / `new AuthenticationException(msg)` /
5317            // `new AuthorizationException(msg)` directly, and none of the three
5318            // has an entry in `Errors.java`, so no code reaches them. They are
5319            // the rows `TransactionExceptionHierarchyTest
5320            // .testInvalidConfigurationExceptionHierarchy` asserts for the two
5321            // base classes.
5322            // ApiException -> KafkaException
5323            (
5324                "Api",
5325                Error::Api(ApiError::new("generic")),
5326                [
5327                    true, true, false, false, false, false, false, false, false, false, false, false, false, false,
5328                    false, false, false,
5329                ],
5330            ),
5331            // AuthenticationException -> InvalidConfigurationException -> ApiException
5332            // -> KafkaException, and fatal per `RequestUtils.isFatalException`.
5333            (
5334                "Authentication",
5335                Error::Authentication(AuthenticationError::new("bad credentials")),
5336                [
5337                    true, true, false, false, false, false, true, false, false, false, false, false, false, true,
5338                    false, true, false,
5339                ],
5340            ),
5341            // AuthorizationException -> InvalidConfigurationException -> ApiException
5342            // -> KafkaException, and fatal per `RequestUtils.isFatalException`.
5343            (
5344                "Authorization",
5345                Error::Authorization(AuthorizationError::new("not authorized")),
5346                [
5347                    true, true, false, false, false, false, true, false, false, false, false, false, false, false,
5348                    true, true, false,
5349                ],
5350            ),
5351            // TopicAuthorizationException -> AuthorizationException -> ApiException -> KafkaException
5352            (
5353                "TopicAuthorization",
5354                Error::topic_authorization(HashSet::new()),
5355                [
5356                    true, true, false, false, false, false, true, false, false, false, false, false, false, false,
5357                    true, true, false,
5358                ],
5359            ),
5360            // GroupAuthorizationException -> AuthorizationException -> ApiException -> KafkaException
5361            (
5362                "GroupAuthorization",
5363                Error::group_authorization("g"),
5364                [
5365                    true, true, false, false, false, false, true, false, false, false, false, false, false, false,
5366                    true, true, false,
5367                ],
5368            ),
5369            // InvalidTopicException -> ApiException -> KafkaException
5370            (
5371                "InvalidTopic",
5372                Error::invalid_topics(HashSet::new()),
5373                [
5374                    true, true, false, false, false, false, true, false, false, false, false, false, false, false,
5375                    false, false, false,
5376                ],
5377            ),
5378            // ThrottlingQuotaExceededException -> RetriableException -> ApiException -> KafkaException
5379            (
5380                "ThrottlingQuotaExceeded",
5381                Error::throttling_quota_exceeded(1, "throttled"),
5382                [
5383                    true, true, true, false, false, false, false, false, false, false, false, false, false, false,
5384                    false, false, false,
5385                ],
5386            ),
5387            // BufferExhaustedException -> TimeoutException -> RetriableException
5388            // -> ApiException -> KafkaException. It extends TimeoutException, so
5389            // it is retriable — and it reports REQUEST_TIMED_OUT, because Java's
5390            // `Errors.forException` walks up the superclass chain to find a code.
5391            (
5392                "BufferExhausted",
5393                Error::buffer_exhausted("full"),
5394                [
5395                    true, true, true, false, true, false, false, false, false, false, false, false, false, false,
5396                    false, false, false,
5397                ],
5398            ),
5399            // TimeoutException -> RetriableException -> ApiException -> KafkaException
5400            (
5401                "Timeout",
5402                Error::timeout("late"),
5403                [
5404                    true, true, true, false, true, false, false, false, false, false, false, false, false, false,
5405                    false, false, false,
5406                ],
5407            ),
5408            // RecordTooLargeException -> ApiException -> KafkaException
5409            (
5410                "RecordTooLarge",
5411                Error::record_too_large("big"),
5412                [
5413                    true, true, false, false, false, false, false, false, false, false, false, false, false, false,
5414                    false, false, false,
5415                ],
5416            ),
5417            // SchemaException -> KafkaException (NOT an ApiException), like
5418            // `SerializationException`.
5419            (
5420                "Schema",
5421                Error::schema("Buffer underflow"),
5422                [
5423                    true, false, false, false, false, false, false, false, false, false, false, false, false, false,
5424                    false, false, false,
5425                ],
5426            ),
5427            // CorrelationIdMismatchException -> java.lang.IllegalStateException:
5428            // outside the hierarchy entirely, so it reads like the `LocalIllegalState`
5429            // row below rather than like a `KafkaException`.
5430            (
5431                "CorrelationIdMismatch",
5432                Error::correlation_id_mismatch("ids disagree", 7, 9),
5433                [
5434                    false, false, false, false, false, false, false, false, false, false, false, false, false, false,
5435                    false, false, false,
5436                ],
5437            ),
5438            // SerializationException -> KafkaException (NOT an ApiException)
5439            (
5440                "Serialization",
5441                Error::serialization("bad"),
5442                [
5443                    true, false, false, false, false, false, false, false, false, false, false, false, true, false,
5444                    false, false, false,
5445                ],
5446            ),
5447            // WakeupException -> KafkaException (NOT an ApiException)
5448            (
5449                "Wakeup",
5450                Error::wakeup("woken"),
5451                [
5452                    true, false, false, false, false, false, false, false, false, false, false, false, false, false,
5453                    false, false, false,
5454                ],
5455            ),
5456            // BootstrapResolutionException -> KafkaException (NOT an ApiException,
5457            // KIP-909): non-wire, so it answers only `is_kafka_error`.
5458            (
5459                "BootstrapResolution",
5460                Error::BootstrapResolution(BootstrapResolutionError::new("unresolvable")),
5461                [
5462                    true, false, false, false, false, false, false, false, false, false, false, false, false, false,
5463                    false, false, false,
5464                ],
5465            ),
5466            // The three codes Kafka 4.4 adds are plain ApiExceptions, not fatal.
5467            // GroupDeletionFailedException -> ApiException -> KafkaException
5468            (
5469                "GroupDeletionFailed (from the code)",
5470                Error::new(Errors::GroupDeletionFailed),
5471                [
5472                    true, true, false, false, false, false, false, false, false, false, false, false, false, false,
5473                    false, false, false,
5474                ],
5475            ),
5476            // StreamsTopologyDescriptionUpdateFailedException -> ApiException -> KafkaException
5477            (
5478                "StreamsTopologyDescriptionUpdateFailed (from the code)",
5479                Error::new(Errors::StreamsTopologyDescriptionUpdateFailed),
5480                [
5481                    true, true, false, false, false, false, false, false, false, false, false, false, false, false,
5482                    false, false, false,
5483                ],
5484            ),
5485            // ControllerIdNotRegisteredException -> ApiException -> KafkaException
5486            (
5487                "ControllerIdNotRegistered (from the code)",
5488                Error::new(Errors::ControllerIdNotRegistered),
5489                [
5490                    true, true, false, false, false, false, false, false, false, false, false, false, false, false,
5491                    false, false, false,
5492                ],
5493            ),
5494            // java.lang / java.util runtime exceptions: outside the hierarchy entirely.
5495            (
5496                "LocalIllegalArgument",
5497                Error::local_illegal_argument("bad arg"),
5498                [
5499                    false, false, false, false, false, false, false, false, false, false, false, false, false, false,
5500                    false, false, false,
5501                ],
5502            ),
5503            (
5504                "LocalIllegalState",
5505                Error::local_illegal_state("bad state"),
5506                [
5507                    false, false, false, false, false, false, false, false, false, false, false, false, false, false,
5508                    false, false, false,
5509                ],
5510            ),
5511            (
5512                "LocalConcurrentModification",
5513                Error::local_concurrent_modification("racy"),
5514                [
5515                    false, false, false, false, false, false, false, false, false, false, false, false, false, false,
5516                    false, false, false,
5517                ],
5518            ),
5519            (
5520                "LocalTimeout",
5521                Error::local_timeout("timed out"),
5522                [
5523                    false, false, false, false, false, false, false, false, false, false, false, false, false, false,
5524                    false, false, false,
5525                ],
5526            ),
5527            // `java.lang.UnsupportedOperationException`: NOT the wire-level
5528            // `UnsupportedVersionException`, so `unsupported_version` (and with
5529            // it `fatal`) is false too.
5530            (
5531                "LocalUnsupportedOperation",
5532                Error::local_unsupported_operation("not implemented"),
5533                [
5534                    false, false, false, false, false, false, false, false, false, false, false, false, false, false,
5535                    false, false, false,
5536                ],
5537            ),
5538            // A foreign callback's error: no Java class, outside the hierarchy
5539            // like the runtime exceptions above.
5540            (
5541                "LocalCallback",
5542                Error::local_callback("ValueError: bad", std::ptr::null_mut()),
5543                [
5544                    false, false, false, false, false, false, false, false, false, false, false, false, false, false,
5545                    false, false, false,
5546                ],
5547            ),
5548            // A bare `KafkaException`: inside the hierarchy, but the parent of
5549            // `ApiException` rather than an instance of it, so it answers `true`
5550            // to `is_kafka_error` and `false` to every other predicate.
5551            (
5552                "KafkaError",
5553                Error::kafka_message("Producer closed while send in progress"),
5554                [
5555                    true, false, false, false, false, false, false, false, false, false, false, false, false, false,
5556                    false, false, false,
5557                ],
5558            ),
5559            // Consumer-package classes: `LogTruncationException extends
5560            // OffsetOutOfRangeException extends InvalidOffsetException`, so a
5561            // log truncation answers `true` to both consumer predicates — Java's
5562            // `catch (OffsetOutOfRangeException e)` catches it.
5563            (
5564                "ConsumerOffsetOutOfRange",
5565                Error::ConsumerOffsetOutOfRange(ConsumerOffsetOutOfRangeError::new(HashMap::new())),
5566                [
5567                    true, false, false, false, false, false, false, false, false, true, true, false, false, false,
5568                    false, false, false,
5569                ],
5570            ),
5571            (
5572                "ConsumerLogTruncation",
5573                Error::ConsumerLogTruncation(Box::new(ConsumerLogTruncationError::new(HashMap::new(), HashMap::new()))),
5574                [
5575                    true, false, false, false, false, false, false, false, false, true, true, false, false, false,
5576                    false, false, false,
5577                ],
5578            ),
5579            // `CommitFailedException extends KafkaException` — not an ApiException.
5580            (
5581                "ConsumerCommitFailed",
5582                Error::ConsumerCommitFailed(ConsumerCommitFailedError::new("m")),
5583                [
5584                    true, false, false, false, false, false, false, false, false, false, false, false, false, false,
5585                    false, false, false,
5586                ],
5587            ),
5588            // `Error::new(code)` resolves the code to its own class (Java's
5589            // `Errors.exception()`), so these two rows check the classes the
5590            // wire codes name — NOT the bare `KafkaError` variant, which
5591            // `Error::new` now only yields for `Errors::None`.
5592            // NOT_LEADER_OR_FOLLOWER: InvalidMetadataException -> RefreshRetriableException
5593            // -> RetriableException -> ApiException -> KafkaException.
5594            (
5595                "NotLeaderOrFollower (from the code)",
5596                Error::new(Errors::NotLeaderOrFollower),
5597                [
5598                    true, true, true, true, false, true, false, false, false, false, false, false, false, false, false,
5599                    false, false,
5600                ],
5601            ),
5602            // SASL_AUTHENTICATION_FAILED: AuthenticationException -> ApiException, and fatal.
5603            (
5604                "SaslAuthenticationFailed (from the code)",
5605                Error::new(Errors::SaslAuthenticationFailed),
5606                [
5607                    true, true, false, false, false, false, true, false, false, false, false, false, false, true,
5608                    false, true, false,
5609                ],
5610            ),
5611            // UNSUPPORTED_VERSION: UnsupportedVersionException -> InvalidConfigurationException
5612            // -> ApiException -> KafkaException, and fatal per `RequestUtils.isFatalException`.
5613            // Intermediate (already in 4.3.1, through the `NoBatched*`
5614            // subclasses); Kafka 4.4 adds the `UnsupportedProtocolFieldException`
5615            // subclass, a crate-private kind of the same variant that answers alike.
5616            (
5617                "UnsupportedVersion (from the code)",
5618                Error::new(Errors::UnsupportedVersion),
5619                [
5620                    true, true, false, false, false, false, true, false, false, false, false, false, false, false,
5621                    false, true, true,
5622                ],
5623            ),
5624            (
5625                "UnsupportedProtocolField (crate-private subclass)",
5626                crate::common::internals::UnsupportedProtocolFieldError::with_message("m"),
5627                [
5628                    true, true, false, false, false, false, true, false, false, false, false, false, false, false,
5629                    false, true, true,
5630                ],
5631            ),
5632        ];
5633
5634        for (name, err, expected) in cases {
5635            let actual = [
5636                err.is_kafka_error(),
5637                err.is_api_error(),
5638                err.is_retriable_error(),
5639                err.is_refresh_retriable_error(),
5640                err.is_timeout_error(),
5641                err.is_invalid_metadata_error(),
5642                err.is_invalid_configuration_error(),
5643                err.is_application_recoverable_error(),
5644                err.is_invalid_offset_error(),
5645                err.is_consumer_invalid_offset_error(),
5646                err.is_consumer_offset_out_of_range_error(),
5647                err.is_out_of_order_sequence_error(),
5648                err.is_serialization_error(),
5649                err.is_authentication_error(),
5650                err.is_authorization_error(),
5651                crate::common::requests::RequestUtils::is_fatal_error(err),
5652                err.is_unsupported_version_error(),
5653            ];
5654            assert_eq!(
5655                &actual, expected,
5656                "{name}: predicate vector diverges from the Java extends chain \
5657                 (order: kafka, api, retriable, refresh_retriable, timeout, invalid_metadata, invalid_configuration, application_recoverable, invalid_offset, consumer_invalid_offset, consumer_offset_out_of_range, out_of_order_sequence, serialization, authentication, authorization, fatal, unsupported_version)"
5658            );
5659        }
5660    }
5661
5662    /// `message()` and `Display` are two different Java methods and must stay
5663    /// that way: `Throwable.getMessage()` returns the bare text, while
5664    /// `Throwable.toString()` is `getClass().getName() + ": " + message`.
5665    ///
5666    /// Both are delegated to the payload now, so this pins each variant's pair
5667    /// and, for the message-only errors, that `Display` is exactly
5668    /// `"<TypeName>: <message>"`.
5669    #[test]
5670    fn message_is_the_bare_text_and_display_adds_the_class_name() {
5671        let message_only: &[(&str, Error)] = &[
5672            ("LocalIllegalArgumentError", Error::local_illegal_argument("boom")),
5673            ("LocalIllegalStateError", Error::local_illegal_state("boom")),
5674            ("LocalConcurrentModificationError", Error::local_concurrent_modification("boom")),
5675            ("LocalUnsupportedOperationError", Error::local_unsupported_operation("boom")),
5676            ("TimeoutError", Error::timeout("boom")),
5677            ("RecordTooLargeError", Error::record_too_large("boom")),
5678            ("SerializationError", Error::serialization("boom")),
5679            ("WakeupError", Error::wakeup("boom")),
5680        ];
5681        for (type_name, err) in message_only {
5682            assert_eq!(err.message(), "boom", "{type_name}: message() must be the bare text");
5683            assert_eq!(
5684                err.to_string(),
5685                format!("{type_name}: boom"),
5686                "{type_name}: Display must prefix the class name"
5687            );
5688        }
5689
5690        // Payloads wrapping a `KafkaError` report its message — the custom one
5691        // when set, otherwise the error code's default text. The old `message()`
5692        // reached these through a `_ =>` arm whose "Unknown error" fallback was
5693        // unreachable; delegation makes each payload answer for itself.
5694        assert_eq!(
5695            Error::new(Errors::RequestTimedOut).message(),
5696            Errors::RequestTimedOut.message(),
5697            "bare KafkaError falls back to the code's default text"
5698        );
5699        assert_eq!(
5700            Error::with_message(Errors::RequestTimedOut, "custom").message(),
5701            "custom",
5702            "a custom message wins over the code's default"
5703        );
5704        assert_eq!(Error::buffer_exhausted("pool full").message(), "pool full");
5705        assert_eq!(
5706            Error::group_authorization_with_message("g1", "not authorized").message(),
5707            "not authorized"
5708        );
5709        assert_eq!(Error::throttling_quota_exceeded(42, "throttled").message(), "throttled");
5710
5711        // The three stateful auth/topic classes format their state into the
5712        // message, exactly as Java's single-argument constructors /
5713        // `forGroupId` do — so it appears in BOTH message() and Display.
5714        // (Java: `TopicAuthorizationException(Set)` ->
5715        // `"Not authorized to access topics: " + set`.)
5716        let topic_auth = Error::topic_authorization(HashSet::from(["t1".to_string()]));
5717        assert_eq!(topic_auth.message(), "Not authorized to access topics: [t1]");
5718        assert_eq!(
5719            topic_auth.to_string(),
5720            "TopicAuthorizationError: Not authorized to access topics: [t1]"
5721        );
5722
5723        let group_auth = Error::group_authorization("g1");
5724        assert_eq!(group_auth.message(), "Not authorized to access group: g1");
5725        assert_eq!(
5726            group_auth.to_string(),
5727            "GroupAuthorizationError: Not authorized to access group: g1"
5728        );
5729
5730        let invalid_topics = Error::invalid_topics(HashSet::from(["t1".to_string()]));
5731        assert_eq!(invalid_topics.message(), "Invalid topics: [t1]");
5732        assert_eq!(invalid_topics.to_string(), "InvalidTopicError: Invalid topics: [t1]");
5733
5734        // The `Errors` registry (`exception()` path) still yields the code's
5735        // default message with empty state, matching Java's `::new` builder.
5736        assert_eq!(
5737            Errors::TopicAuthorizationFailed.error().unwrap().message(),
5738            Errors::TopicAuthorizationFailed.message()
5739        );
5740        assert_eq!(
5741            Errors::GroupAuthorizationFailed.error().unwrap().message(),
5742            Errors::GroupAuthorizationFailed.message()
5743        );
5744        assert_eq!(
5745            Errors::InvalidTopicError.error().unwrap().message(),
5746            Errors::InvalidTopicError.message()
5747        );
5748    }
5749
5750    /// The classes translated into `common::errors` answer their own code and
5751    /// ancestry, without an embedded [`KafkaError`].
5752    ///
5753    /// `TimeoutError` moving into that module is a deliberate behaviour change:
5754    /// it used to carry no code, so `code()` was `-1`. Java associates a code
5755    /// with an exception *class* (`Errors.forException`, `CLASS_TO_ERROR`), and
5756    /// `REQUEST_TIMED_OUT` maps to `TimeoutException` — including for
5757    /// client-side timeouts, which is why the code is unconditional.
5758    #[test]
5759    fn translated_classes_answer_their_own_code() {
5760        use crate::common::errors::{NetworkError, NotCoordinatorError, TimeoutError};
5761
5762        let timeout = Error::timeout("late");
5763        assert_eq!(timeout.error(), Errors::RequestTimedOut);
5764        // Java: `TimeoutException` carries `Errors.REQUEST_TIMED_OUT`.
5765        assert_eq!(timeout.error().code(), 7, "a timeout error is Errors.REQUEST_TIMED_OUT");
5766        assert_eq!(timeout.message(), "late");
5767        assert!(timeout.is_retriable_error());
5768
5769        // `with_default_message()` is Java's `Errors.exception()`: the literal
5770        // stays on the `Errors` constant and is handed to the class.
5771        let defaulted = TimeoutError::with_default_message();
5772        assert_eq!(defaulted.message(), Errors::RequestTimedOut.message());
5773
5774        // NetworkException extends InvalidMetadataException extends
5775        // RefreshRetriableException extends RetriableException.
5776        let net = NetworkError::new("disconnected");
5777        assert_eq!(ErrorCode::error(&net), Errors::NetworkError);
5778        assert!(ErrorHierarchy::is_invalid_metadata_error(&net));
5779        assert!(ErrorHierarchy::is_refresh_retriable_error(&net));
5780        assert!(ErrorHierarchy::is_retriable_error(&net));
5781        assert_eq!(net.to_string(), "NetworkError: disconnected");
5782
5783        // NotCoordinatorException is RefreshRetriable but NOT InvalidMetadata.
5784        let nc = NotCoordinatorError::new("wrong coordinator");
5785        assert!(ErrorHierarchy::is_refresh_retriable_error(&nc));
5786        assert!(!ErrorHierarchy::is_invalid_metadata_error(&nc));
5787
5788        // ThrottlingQuotaExceededError keeps its extra field through the move.
5789        let throttled = Error::throttling_quota_exceeded(250, "slow down");
5790        assert_eq!(throttled.throttle_time_ms(), Some(250));
5791        assert_eq!(throttled.error(), Errors::ThrottlingQuotaExceeded);
5792        assert!(throttled.is_retriable_error());
5793    }
5794
5795    /// `Error::KafkaError` now means a *bare* `KafkaException` — every code maps
5796    /// to its own class through [`Errors::error`], so the variant is only reached
5797    /// for [`Errors::None`] or by constructing it directly.
5798    ///
5799    /// It is therefore NOT an `ApiException`: `KafkaException` is that class's
5800    /// parent, not an instance of it. While the variant stood in for every coded
5801    /// error it had to answer `true`, which is the assumption this pins closed.
5802    #[test]
5803    fn bare_kafka_error_is_not_an_api_error() {
5804        let bare = Error::KafkaError(KafkaError::new(Errors::None));
5805        assert!(bare.is_kafka_error());
5806        // Java: `KafkaException` is `ApiException`'s parent, not an instance of it.
5807        assert!(!bare.is_api_error(), "a bare Kafka error is the parent class, not an API error");
5808        assert!(!bare.is_retriable_error());
5809        assert!(!crate::common::requests::RequestUtils::is_fatal_error(&bare));
5810
5811        // A code no longer produces this variant at all.
5812        assert!(matches!(Error::new(Errors::NetworkError), Error::Network(_)));
5813        assert!(matches!(Error::new(Errors::None), Error::KafkaError(_)));
5814    }
5815
5816    /// `is_transaction_abortable_error` is the class predicate for a leaf class.
5817    /// It is still an [`ErrorHierarchy`] method, so that a subclass Java adds
5818    /// later answers `true` too.
5819    ///
5820    /// Note the confusable neighbour: `TransactionAbortableException` (code 120,
5821    /// "you may abort and carry on") is a different Java class from
5822    /// `TransactionAbortedException` (no code, "the transaction was aborted, the
5823    /// record was not written").
5824    #[test]
5825    fn transaction_abortable_is_a_class_predicate() {
5826        let abortable = Error::new(Errors::TransactionAbortable);
5827        assert!(abortable.is_transaction_abortable_error());
5828        assert_eq!(abortable.error().code(), 120);
5829
5830        // Different class, despite the near-identical name.
5831        let aborted = Error::TransactionAborted(TransactionAbortedError::new("aborted"));
5832        assert!(!aborted.is_transaction_abortable_error());
5833
5834        for other in [
5835            Error::timeout("x"),
5836            Error::new(Errors::NetworkError),
5837            Error::local_illegal_state("x"),
5838        ] {
5839            assert!(!other.is_transaction_abortable_error(), "{other:?}");
5840        }
5841    }
5842
5843    /// A `KafkaException` subclass is always a `KafkaException`, and anything
5844    /// retriable through a refresh is retriable. Guards against a payload
5845    /// overriding a narrow predicate while forgetting its ancestors.
5846    #[test]
5847    fn predicate_nesting_holds_for_every_variant() {
5848        let errors = [
5849            Error::topic_authorization(HashSet::new()),
5850            Error::group_authorization("g"),
5851            Error::invalid_topics(HashSet::new()),
5852            Error::throttling_quota_exceeded(1, "throttled"),
5853            Error::buffer_exhausted("full"),
5854            Error::timeout("late"),
5855            Error::record_too_large("big"),
5856            Error::serialization("bad"),
5857            Error::wakeup("woken"),
5858            Error::local_illegal_argument("bad arg"),
5859            Error::local_illegal_state("bad state"),
5860            Error::local_concurrent_modification("racy"),
5861            Error::local_unsupported_operation("not implemented"),
5862            Error::new(Errors::NotLeaderOrFollower),
5863            Error::new(Errors::SaslAuthenticationFailed),
5864            Error::ConsumerOffsetOutOfRange(ConsumerOffsetOutOfRangeError::new(std::collections::HashMap::new())),
5865            Error::ConsumerLogTruncation(Box::new(ConsumerLogTruncationError::new(
5866                std::collections::HashMap::new(),
5867                std::collections::HashMap::new(),
5868            ))),
5869            Error::buffer_exhausted("pool full"),
5870        ];
5871
5872        for err in &errors {
5873            if err.is_api_error() {
5874                // Java: `ApiException extends KafkaException`.
5875                assert!(err.is_kafka_error(), "{err}: an API error must be a Kafka error");
5876            }
5877            if err.is_retriable_error() {
5878                // Java: `RetriableException extends ApiException`.
5879                assert!(err.is_api_error(), "{err}: a retriable error must be an API error");
5880            }
5881            if err.is_refresh_retriable_error() {
5882                assert!(err.is_retriable_error(), "{err}: RefreshRetriable must be Retriable");
5883            }
5884            if err.is_invalid_metadata_error() {
5885                assert!(
5886                    err.is_refresh_retriable_error(),
5887                    "{err}: InvalidMetadata must be RefreshRetriable"
5888                );
5889            }
5890            if err.is_authentication_error() || err.is_authorization_error() {
5891                // Kafka 4.2: both extend InvalidConfigurationException, NOT
5892                // ApiException directly.
5893                assert!(
5894                    err.is_invalid_configuration_error(),
5895                    "{err}: auth/authz errors must be invalid-configuration errors"
5896                );
5897                assert!(
5898                    crate::common::requests::RequestUtils::is_fatal_error(err),
5899                    "{err}: auth/authz errors are fatal"
5900                );
5901                assert!(!err.is_retriable_error(), "{err}: auth/authz errors are not retriable");
5902            }
5903            if err.is_invalid_configuration_error()
5904                || err.is_application_recoverable_error()
5905                || err.is_invalid_offset_error()
5906                || err.is_out_of_order_sequence_error()
5907            {
5908                assert!(
5909                    err.is_api_error(),
5910                    "{err}: invalid-configuration / application-recoverable / invalid-offset / \
5911                     out-of-order-sequence errors are all API errors"
5912                );
5913            }
5914            if err.is_timeout_error() {
5915                // TimeoutException extends RetriableException.
5916                assert!(err.is_retriable_error(), "{err}: a timeout error is retriable");
5917            }
5918            if err.is_unsupported_version_error() {
5919                // UnsupportedVersionException extends InvalidConfigurationException.
5920                assert!(
5921                    err.is_invalid_configuration_error(),
5922                    "{err}: an unsupported-version error is an invalid-configuration error"
5923                );
5924            }
5925            if err.is_consumer_offset_out_of_range_error() {
5926                // consumer OffsetOutOfRangeException extends consumer
5927                // InvalidOffsetException.
5928                assert!(
5929                    err.is_consumer_invalid_offset_error(),
5930                    "{err}: a consumer offset-out-of-range error is a consumer invalid-offset error"
5931                );
5932            }
5933            if err.is_consumer_invalid_offset_error() {
5934                // The consumer's InvalidOffsetException extends KafkaException,
5935                // NOT ApiException — unlike the common.errors class of the same
5936                // name.
5937                assert!(err.is_kafka_error(), "{err}: a consumer invalid-offset error is a Kafka error");
5938                assert!(
5939                    !err.is_api_error(),
5940                    "{err}: a consumer invalid-offset error is NOT an API error"
5941                );
5942            }
5943            if err.is_serialization_error() {
5944                // SerializationException extends KafkaException directly.
5945                assert!(err.is_kafka_error(), "{err}: a serialization error is a Kafka error");
5946                assert!(!err.is_api_error(), "{err}: a serialization error is NOT an API error");
5947            }
5948        }
5949    }
5950    // -----------------------------------------------------------------------
5951    // TransactionExceptionHierarchyTest.java (Apache Kafka 4.2,
5952    // clients/src/test/java/org/apache/kafka/common/errors/
5953    // TransactionExceptionHierarchyTest.java)
5954    //
5955    // Java asserts on `Class.isAssignableFrom`, which it can do because the
5956    // hierarchy is the type system. Rust has no subclassing, so the flattened
5957    // enum answers through the payload's `extends:` list — these four tests are
5958    // that list checked against Java's, class by class, over exactly the Java
5959    // `@ValueSource` sets. Each parameterized method becomes a loop, per DoD #3.
5960    //
5961    // Java names two classes that this crate carries as `Error` variants with no
5962    // protocol code — `AuthenticationException` and `AuthorizationException` —
5963    // and they are the reason this file is translated rather than left to the
5964    // code-level tables in `protocol/errors.rs`, which can only reach classes a
5965    // wire code names.
5966    // -----------------------------------------------------------------------
5967
5968    /// `testRetriableExceptionHierarchy`: these six extend `RetriableException`
5969    /// and must NOT extend `RefreshRetriableException`.
5970    ///
5971    /// Java's javadoc gives the stake: "Using `RefreshRetriableException`
5972    /// changes the exception handling behavior, so only exceptions extending
5973    /// `RetriableException` directly are considered valid here."
5974    #[test]
5975    fn transaction_hierarchy_retriable_classes() {
5976        let classes: &[(&str, Error)] = &[
5977            ("TimeoutError", Error::Timeout(TimeoutError::new("m"))),
5978            (
5979                "NotEnoughReplicasError",
5980                Error::NotEnoughReplicas(NotEnoughReplicasError::new("m")),
5981            ),
5982            (
5983                "CoordinatorLoadInProgressError",
5984                Error::CoordinatorLoadInProgress(CoordinatorLoadInProgressError::new("m")),
5985            ),
5986            ("CorruptRecordError", Error::CorruptRecord(CorruptRecordError::new("m"))),
5987            (
5988                "NotEnoughReplicasAfterAppendError",
5989                Error::NotEnoughReplicasAfterAppend(NotEnoughReplicasAfterAppendError::new("m")),
5990            ),
5991            (
5992                "ConcurrentTransactionsError",
5993                Error::ConcurrentTransactions(ConcurrentTransactionsError::new("m")),
5994            ),
5995        ];
5996        for (name, error) in classes {
5997            assert!(error.is_retriable_error(), "{name} should be a retriable error");
5998            assert!(
5999                !error.is_refresh_retriable_error(),
6000                "{name} should NOT be a refresh-retriable error"
6001            );
6002        }
6003    }
6004
6005    /// `testRefreshRetriableException`: `RefreshRetriableException extends
6006    /// RetriableException`.
6007    ///
6008    /// Java asserts it on the intermediate class itself. The flattened enum has
6009    /// no such class, so the equivalent statement is that the nesting holds for
6010    /// every error: nothing may answer `true` to the child predicate and `false`
6011    /// to the parent's. Asserted over the same class set the next test uses,
6012    /// plus every protocol code — the code-level half is also covered by
6013    /// `errors.rs`'s `test_hierarchy_predicates_nest`.
6014    #[test]
6015    fn transaction_hierarchy_refresh_retriable_is_retriable() {
6016        for code in -1i16..=200 {
6017            let error = Errors::for_code(code);
6018            if let Some(error) = error.error() {
6019                assert!(
6020                    !error.is_refresh_retriable_error() || error.is_retriable_error(),
6021                    "{error:?}: a refresh-retriable error should also be a retriable error"
6022                );
6023            }
6024        }
6025    }
6026
6027    /// `testRefreshRetriableExceptionHierarchy`: these four extend
6028    /// `RefreshRetriableException` — and therefore `RetriableException`.
6029    #[test]
6030    fn transaction_hierarchy_refresh_retriable_classes() {
6031        let classes: &[(&str, Error)] = &[
6032            (
6033                "UnknownTopicOrPartitionError",
6034                Error::UnknownTopicOrPartition(UnknownTopicOrPartitionError::new("m")),
6035            ),
6036            (
6037                "NotLeaderOrFollowerError",
6038                Error::NotLeaderOrFollower(NotLeaderOrFollowerError::new("m")),
6039            ),
6040            ("NotCoordinatorError", Error::NotCoordinator(NotCoordinatorError::new("m"))),
6041            (
6042                "CoordinatorNotAvailableError",
6043                Error::CoordinatorNotAvailable(CoordinatorNotAvailableError::new("m")),
6044            ),
6045        ];
6046        for (name, error) in classes {
6047            assert!(error.is_refresh_retriable_error(), "{name} should be a refresh-retriable error");
6048            assert!(error.is_retriable_error(), "{name} should be a retriable error");
6049        }
6050    }
6051
6052    /// `testApplicationRecoverableExceptionHierarchy`: these six extend
6053    /// `ApplicationRecoverableException`.
6054    #[test]
6055    fn transaction_hierarchy_application_recoverable_classes() {
6056        let classes: &[(&str, Error)] = &[
6057            (
6058                "FencedInstanceIdError",
6059                Error::FencedInstanceId(FencedInstanceIdError::new("m")),
6060            ),
6061            (
6062                "IllegalGenerationError",
6063                Error::IllegalGeneration(IllegalGenerationError::new("m")),
6064            ),
6065            (
6066                "InvalidPidMappingError",
6067                Error::InvalidPidMapping(InvalidPidMappingError::new("m")),
6068            ),
6069            (
6070                "InvalidProducerEpochError",
6071                Error::InvalidProducerEpoch(InvalidProducerEpochError::new("m")),
6072            ),
6073            ("ProducerFencedError", Error::ProducerFenced(ProducerFencedError::new("m"))),
6074            ("UnknownMemberIdError", Error::UnknownMemberId(UnknownMemberIdError::new("m"))),
6075        ];
6076        for (name, error) in classes {
6077            assert!(
6078                error.is_application_recoverable_error(),
6079                "{name} should be an application-recoverable error"
6080            );
6081        }
6082    }
6083
6084    /// `testInvalidConfigurationExceptionHierarchy`: these twelve extend
6085    /// `InvalidConfigurationException`.
6086    ///
6087    /// Wider than the name suggests: in Kafka 4.2 both `AuthenticationException`
6088    /// and `AuthorizationException` extend it, which is why the two authorization
6089    /// subclasses and the two concrete bases are in Java's `@ValueSource`.
6090    /// [`Error::Authentication`] and [`Error::Authorization`] appear in no other
6091    /// predicate test — a wire code cannot reach them.
6092    #[test]
6093    fn transaction_hierarchy_invalid_configuration_classes() {
6094        let classes: &[(&str, Error)] = &[
6095            ("AuthenticationError", Error::Authentication(AuthenticationError::new("m"))),
6096            ("AuthorizationError", Error::Authorization(AuthorizationError::new("m"))),
6097            (
6098                "ClusterAuthorizationError",
6099                Error::ClusterAuthorization(ClusterAuthorizationError::new("m")),
6100            ),
6101            (
6102                "TransactionalIdAuthorizationError",
6103                Error::TransactionalIdAuthorization(TransactionalIdAuthorizationError::new("m")),
6104            ),
6105            (
6106                "UnsupportedVersionError",
6107                Error::UnsupportedVersion(UnsupportedVersionError::new("m")),
6108            ),
6109            (
6110                "UnsupportedForMessageFormatError",
6111                Error::UnsupportedForMessageFormat(UnsupportedForMessageFormatError::new("m")),
6112            ),
6113            ("InvalidRecordError", Error::InvalidRecord(InvalidRecordError::new("m"))),
6114            (
6115                "InvalidRequiredAcksError",
6116                Error::InvalidRequiredAcks(InvalidRequiredAcksError::new("m")),
6117            ),
6118            (
6119                "RecordBatchTooLargeError",
6120                Error::RecordBatchTooLarge(RecordBatchTooLargeError::new("m")),
6121            ),
6122            ("InvalidTopicError", Error::invalid_topics(HashSet::from(["t".to_string()]))),
6123            (
6124                "TopicAuthorizationError",
6125                Error::topic_authorization(HashSet::from(["t".to_string()])),
6126            ),
6127            ("GroupAuthorizationError", Error::group_authorization("g")),
6128        ];
6129        for (name, error) in classes {
6130            assert!(
6131                error.is_invalid_configuration_error(),
6132                "{name} should be an invalid-configuration error"
6133            );
6134        }
6135    }
6136}