pub enum RocketMQError {
Show 53 variants
Network(NetworkError),
Serialization(SerializationError),
Protocol(ProtocolError),
BrokerNotFound {
name: String,
},
BrokerRegistrationFailed {
name: String,
reason: String,
},
BrokerOperationFailed {
operation: &'static str,
code: i32,
message: String,
broker_addr: Option<String>,
},
TopicNotExist {
topic: String,
},
QueueNotExist {
topic: String,
queue_id: i32,
},
SubscriptionGroupNotExist {
group: String,
},
QueueIdOutOfRange {
topic: String,
queue_id: i32,
max: i32,
},
MessageTooLarge {
actual: usize,
limit: usize,
},
MessageValidationFailed {
reason: String,
},
RetryLimitExceeded {
group: String,
current: i32,
max: i32,
},
TransactionRejected,
BrokerPermissionDenied {
operation: String,
},
NotMasterBroker {
master_address: String,
},
MessageLookupFailed {
offset: i64,
},
TopicSendingForbidden {
topic: String,
},
BrokerAsyncTaskFailed {
task: &'static str,
context: String,
source: Box<dyn Error + Sync + Send>,
},
RequestBodyInvalid {
operation: &'static str,
reason: String,
},
RequestHeaderError(String),
ResponseProcessFailed {
operation: &'static str,
reason: String,
},
RouteNotFound {
topic: String,
},
RouteInconsistent {
topic: String,
reason: String,
},
RouteRegistrationConflict {
broker_name: String,
reason: String,
},
RouteVersionConflict {
expected: u64,
actual: u64,
},
ClusterNotFound {
cluster: String,
},
ClientNotStarted,
ClientAlreadyStarted,
ClientShuttingDown,
ClientInvalidState {
expected: &'static str,
actual: String,
},
ProducerNotAvailable,
ConsumerNotAvailable,
Tools(ToolsError),
StorageReadFailed {
path: String,
reason: String,
},
StorageWriteFailed {
path: String,
reason: String,
},
StorageCorrupted {
path: String,
},
StorageOutOfSpace {
path: String,
},
StorageLockFailed {
path: String,
},
ConfigParseFailed {
key: &'static str,
reason: String,
},
ConfigMissing {
key: &'static str,
},
ConfigInvalidValue {
key: &'static str,
value: String,
reason: String,
},
ControllerNotLeader {
leader_id: Option<u64>,
},
ControllerRaftError {
reason: String,
},
ControllerConsensusTimeout {
operation: &'static str,
timeout_ms: u64,
},
ControllerSnapshotFailed {
reason: String,
},
IO(Error),
IllegalArgument(String),
Timeout {
operation: &'static str,
timeout_ms: u64,
},
Internal(String),
Service(ServiceError),
InvalidVersionOrdinal(u32),
Legacy(String),
}Expand description
Main error type for all RocketMQ operations
This enum provides a unified error system across all RocketMQ crates. Each variant represents a logical category of errors with rich context information.
§Design Principles
- Semantic: Each error clearly expresses what went wrong
- Performance: Minimal heap allocations, use of &’static str where possible
- Debuggability: Rich context for production debugging
- Ergonomics: Automatic conversions via From trait
§Examples
use rocketmq_error::RocketMQError;
use rocketmq_error::RocketMQResult;
fn send_message(addr: &str) -> RocketMQResult<()> {
// Create a network error
if addr.is_empty() {
return Err(RocketMQError::network_connection_failed(
"localhost:9876",
"empty address",
));
}
Ok(())
}Variants§
Network(NetworkError)
Network operation errors (connection, timeout, send/receive failures)
Serialization(SerializationError)
Serialization/deserialization errors (encoding, decoding, format validation)
Protocol(ProtocolError)
RocketMQ protocol errors (invalid commands, version mismatch, etc.)
BrokerNotFound
Broker not found
BrokerRegistrationFailed
Broker registration failed
BrokerOperationFailed
Broker operation failed with error code
TopicNotExist
Topic does not exist
QueueNotExist
Queue does not exist
SubscriptionGroupNotExist
Subscription group not found
QueueIdOutOfRange
Queue ID out of range
MessageTooLarge
Message body too large
MessageValidationFailed
Message validation failed
RetryLimitExceeded
Retry limit exceeded
TransactionRejected
Transaction message rejected
BrokerPermissionDenied
Broker permission denied
NotMasterBroker
Not master broker
MessageLookupFailed
Message lookup failed
TopicSendingForbidden
Topic sending forbidden
BrokerAsyncTaskFailed
Async task failed
RequestBodyInvalid
Request body missing or invalid
RequestHeaderError(String)
Request header missing or invalid
ResponseProcessFailed
Response encoding/decoding failed
RouteNotFound
Route information not found
RouteInconsistent
Route data inconsistency detected
RouteRegistrationConflict
Broker registration conflict
RouteVersionConflict
Route state version conflict
ClusterNotFound
Cluster not found
ClientNotStarted
Client not started
ClientAlreadyStarted
Client already started
ClientShuttingDown
Client is shutting down
ClientInvalidState
Invalid client state
ProducerNotAvailable
Producer not available
ConsumerNotAvailable
Consumer not available
Tools(ToolsError)
Tools and admin operation errors
StorageReadFailed
Storage read failed
StorageWriteFailed
Storage write failed
StorageCorrupted
Data corruption detected
StorageOutOfSpace
Out of storage space
StorageLockFailed
Storage lock failed
ConfigParseFailed
Configuration parsing failed
ConfigMissing
Required configuration missing
ConfigInvalidValue
Invalid configuration value
ControllerNotLeader
Not the Raft leader
ControllerRaftError
Raft consensus error
ControllerConsensusTimeout
Consensus operation timeout
ControllerSnapshotFailed
Snapshot operation failed
IO(Error)
IO error from std::io
IllegalArgument(String)
Illegal argument
Timeout
Operation timeout
Internal(String)
Internal error (should be rare)
Service(ServiceError)
Service lifecycle error
InvalidVersionOrdinal(u32)
Invalid RocketMQ version ordinal value
Legacy(String)
Legacy error - use specific error types instead
Implementations§
Source§impl RocketMQError
impl RocketMQError
Sourcepub fn network_connection_failed(
addr: impl Into<String>,
reason: impl Into<String>,
) -> RocketMQError
pub fn network_connection_failed( addr: impl Into<String>, reason: impl Into<String>, ) -> RocketMQError
Create a network connection failed error
Sourcepub fn broker_operation_failed(
operation: &'static str,
code: i32,
message: impl Into<String>,
) -> RocketMQError
pub fn broker_operation_failed( operation: &'static str, code: i32, message: impl Into<String>, ) -> RocketMQError
Create a broker operation failed error
Sourcepub fn storage_read_failed(
path: impl Into<String>,
reason: impl Into<String>,
) -> RocketMQError
pub fn storage_read_failed( path: impl Into<String>, reason: impl Into<String>, ) -> RocketMQError
Create a storage read failed error
Sourcepub fn storage_write_failed(
path: impl Into<String>,
reason: impl Into<String>,
) -> RocketMQError
pub fn storage_write_failed( path: impl Into<String>, reason: impl Into<String>, ) -> RocketMQError
Create a storage write failed error
Sourcepub fn illegal_argument(message: impl Into<String>) -> RocketMQError
pub fn illegal_argument(message: impl Into<String>) -> RocketMQError
Create an illegal argument error
Sourcepub fn route_not_found(topic: impl Into<String>) -> RocketMQError
pub fn route_not_found(topic: impl Into<String>) -> RocketMQError
Create a route not found error
Sourcepub fn route_registration_conflict(
broker_name: impl Into<String>,
reason: impl Into<String>,
) -> RocketMQError
pub fn route_registration_conflict( broker_name: impl Into<String>, reason: impl Into<String>, ) -> RocketMQError
Create a route registration conflict error
Sourcepub fn cluster_not_found(cluster: impl Into<String>) -> RocketMQError
pub fn cluster_not_found(cluster: impl Into<String>) -> RocketMQError
Create a cluster not found error
Sourcepub fn request_body_invalid(
operation: &'static str,
reason: impl Into<String>,
) -> RocketMQError
pub fn request_body_invalid( operation: &'static str, reason: impl Into<String>, ) -> RocketMQError
Create a request body invalid error
Sourcepub fn request_header_error(message: impl Into<String>) -> RocketMQError
pub fn request_header_error(message: impl Into<String>) -> RocketMQError
Create a request header error
Sourcepub fn response_process_failed(
operation: &'static str,
reason: impl Into<String>,
) -> RocketMQError
pub fn response_process_failed( operation: &'static str, reason: impl Into<String>, ) -> RocketMQError
Create a response process failed error
Sourcepub fn with_broker_addr(self, addr: impl Into<String>) -> RocketMQError
pub fn with_broker_addr(self, addr: impl Into<String>) -> RocketMQError
Add broker address context to broker operation error
Sourcepub fn validation_error(
field: impl Into<String>,
reason: impl Into<String>,
) -> RocketMQError
pub fn validation_error( field: impl Into<String>, reason: impl Into<String>, ) -> RocketMQError
Create a validation error
Sourcepub fn topic_not_found(topic: impl Into<String>) -> RocketMQError
pub fn topic_not_found(topic: impl Into<String>) -> RocketMQError
Create a topic not found error (alias for TopicNotExist)
Sourcepub fn topic_already_exists(topic: impl Into<String>) -> RocketMQError
pub fn topic_already_exists(topic: impl Into<String>) -> RocketMQError
Create a topic already exists error
Sourcepub fn nameserver_unreachable(addr: impl Into<String>) -> RocketMQError
pub fn nameserver_unreachable(addr: impl Into<String>) -> RocketMQError
Create a nameserver unreachable error
Sourcepub fn nameserver_config_invalid(reason: impl Into<String>) -> RocketMQError
pub fn nameserver_config_invalid(reason: impl Into<String>) -> RocketMQError
Create a nameserver config invalid error
Trait Implementations§
Source§impl Debug for RocketMQError
impl Debug for RocketMQError
Source§impl Display for RocketMQError
impl Display for RocketMQError
Source§impl Error for RocketMQError
impl Error for RocketMQError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ConfigError> for RocketMQError
Available on crate feature with_config only.
impl From<ConfigError> for RocketMQError
with_config only.Source§fn from(e: ConfigError) -> RocketMQError
fn from(e: ConfigError) -> RocketMQError
Source§impl From<Error> for RocketMQError
impl From<Error> for RocketMQError
Source§fn from(source: Error) -> RocketMQError
fn from(source: Error) -> RocketMQError
Source§impl From<Error> for RocketMQError
Available on crate feature with_serde only.
impl From<Error> for RocketMQError
with_serde only.Source§fn from(e: Error) -> RocketMQError
fn from(e: Error) -> RocketMQError
Source§impl From<NetworkError> for RocketMQError
impl From<NetworkError> for RocketMQError
Source§fn from(source: NetworkError) -> RocketMQError
fn from(source: NetworkError) -> RocketMQError
Source§impl From<ProtocolError> for RocketMQError
impl From<ProtocolError> for RocketMQError
Source§fn from(source: ProtocolError) -> RocketMQError
fn from(source: ProtocolError) -> RocketMQError
Source§impl From<RocketmqError> for RocketMQError
Automatic conversion from legacy RocketmqError to unified RocketMQError
impl From<RocketmqError> for RocketMQError
Automatic conversion from legacy RocketmqError to unified RocketMQError
This allows legacy error-producing code to work with new error-expecting code
Source§fn from(err: RocketmqError) -> RocketMQError
fn from(err: RocketmqError) -> RocketMQError
Source§impl From<SerializationError> for RocketMQError
impl From<SerializationError> for RocketMQError
Source§fn from(source: SerializationError) -> RocketMQError
fn from(source: SerializationError) -> RocketMQError
Source§impl From<ToolsError> for RocketMQError
impl From<ToolsError> for RocketMQError
Source§fn from(source: ToolsError) -> RocketMQError
fn from(source: ToolsError) -> RocketMQError
Source§impl From<ServiceError> for RocketMQError
impl From<ServiceError> for RocketMQError
Source§fn from(source: ServiceError) -> RocketMQError
fn from(source: ServiceError) -> RocketMQError
Source§impl From<Utf8Error> for RocketMQError
impl From<Utf8Error> for RocketMQError
Source§fn from(e: Utf8Error) -> RocketMQError
fn from(e: Utf8Error) -> RocketMQError
Auto Trait Implementations§
impl Freeze for RocketMQError
impl !RefUnwindSafe for RocketMQError
impl Send for RocketMQError
impl Sync for RocketMQError
impl Unpin for RocketMQError
impl !UnwindSafe for RocketMQError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.