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 + Send + Sync>,
},
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>,
) -> Self
pub fn network_connection_failed( addr: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a network connection failed error
Sourcepub fn broker_operation_failed(
operation: &'static str,
code: i32,
message: impl Into<String>,
) -> Self
pub fn broker_operation_failed( operation: &'static str, code: i32, message: impl Into<String>, ) -> Self
Create a broker operation failed error
Sourcepub fn storage_read_failed(
path: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn storage_read_failed( path: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a storage read failed error
Sourcepub fn storage_write_failed(
path: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn storage_write_failed( path: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a storage write failed error
Sourcepub fn illegal_argument(message: impl Into<String>) -> Self
pub fn illegal_argument(message: impl Into<String>) -> Self
Create an illegal argument error
Sourcepub fn route_not_found(topic: impl Into<String>) -> Self
pub fn route_not_found(topic: impl Into<String>) -> Self
Create a route not found error
Sourcepub fn route_registration_conflict(
broker_name: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn route_registration_conflict( broker_name: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a route registration conflict error
Sourcepub fn cluster_not_found(cluster: impl Into<String>) -> Self
pub fn cluster_not_found(cluster: impl Into<String>) -> Self
Create a cluster not found error
Sourcepub fn request_body_invalid(
operation: &'static str,
reason: impl Into<String>,
) -> Self
pub fn request_body_invalid( operation: &'static str, reason: impl Into<String>, ) -> Self
Create a request body invalid error
Sourcepub fn request_header_error(message: impl Into<String>) -> Self
pub fn request_header_error(message: impl Into<String>) -> Self
Create a request header error
Sourcepub fn response_process_failed(
operation: &'static str,
reason: impl Into<String>,
) -> Self
pub fn response_process_failed( operation: &'static str, reason: impl Into<String>, ) -> Self
Create a response process failed error
Sourcepub fn with_broker_addr(self, addr: impl Into<String>) -> Self
pub fn with_broker_addr(self, addr: impl Into<String>) -> Self
Add broker address context to broker operation error
Sourcepub fn validation_error(
field: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn validation_error( field: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a validation error
Sourcepub fn topic_not_found(topic: impl Into<String>) -> Self
pub fn topic_not_found(topic: impl Into<String>) -> Self
Create a topic not found error (alias for TopicNotExist)
Sourcepub fn topic_already_exists(topic: impl Into<String>) -> Self
pub fn topic_already_exists(topic: impl Into<String>) -> Self
Create a topic already exists error
Sourcepub fn nameserver_unreachable(addr: impl Into<String>) -> Self
pub fn nameserver_unreachable(addr: impl Into<String>) -> Self
Create a nameserver unreachable error
Sourcepub fn nameserver_config_invalid(reason: impl Into<String>) -> Self
pub fn nameserver_config_invalid(reason: impl Into<String>) -> Self
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<Error> for RocketMQError
impl From<Error> for RocketMQError
Source§impl From<NetworkError> for RocketMQError
impl From<NetworkError> for RocketMQError
Source§fn from(source: NetworkError) -> Self
fn from(source: NetworkError) -> Self
Source§impl From<ProtocolError> for RocketMQError
impl From<ProtocolError> for RocketMQError
Source§fn from(source: ProtocolError) -> Self
fn from(source: ProtocolError) -> Self
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