pub enum RocketMQError {
Show 60 variants
Network(NetworkError),
Serialization(SerializationError),
Protocol(ProtocolError),
Rpc(RpcClientError),
Authentication(AuthError),
Controller(ControllerError),
InvalidProperty(String),
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),
Filter(FilterError),
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),
NotInitialized(String),
MissingRequiredMessageProperty {
property: &'static str,
},
}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(())
}
fn authenticate_user(username: &str) -> RocketMQResult<()> {
// Create an authentication error
if username.is_empty() {
return Err(RocketMQError::user_not_found(""));
}
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.)
Rpc(RpcClientError)
RPC client specific errors (broker lookup, request failures, etc.)
Authentication(AuthError)
Authentication/authorization errors (credential validation, access control, etc.)
Controller(ControllerError)
Controller operation errors (Raft consensus, leader election, broker management, etc.)
InvalidProperty(String)
Invalid message property
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
Filter(FilterError)
Bloom filter and bit array 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)
Use specific error types instead
Legacy error - use specific error types instead
NotInitialized(String)
MissingRequiredMessageProperty
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 network_timeout(addr: impl Into<String>, timeout: Duration) -> Self
pub fn network_timeout(addr: impl Into<String>, timeout: Duration) -> Self
Create a network timeout error
Sourcepub fn network_request_failed(
addr: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn network_request_failed( addr: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a network request failed error
Sourcepub fn deserialization_failed(
format: &'static str,
reason: impl Into<String>,
) -> Self
pub fn deserialization_failed( format: &'static str, reason: impl Into<String>, ) -> Self
Create a deserialization failed error
Sourcepub fn validation_failed(
field: impl Into<String>,
reason: impl Into<String>,
) -> Self
pub fn validation_failed( field: impl Into<String>, reason: impl Into<String>, ) -> Self
Create a validation 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
Sourcepub fn not_initialized(reason: impl Into<String>) -> Self
pub fn not_initialized(reason: impl Into<String>) -> Self
Create a not initialized error
Sourcepub fn authentication_failed(reason: impl Into<String>) -> Self
pub fn authentication_failed(reason: impl Into<String>) -> Self
Create an authentication failed error
Sourcepub fn invalid_credential(reason: impl Into<String>) -> Self
pub fn invalid_credential(reason: impl Into<String>) -> Self
Create an invalid credential error
Sourcepub fn user_not_found(username: impl Into<String>) -> Self
pub fn user_not_found(username: impl Into<String>) -> Self
Create a user not found error
Sourcepub fn invalid_signature(reason: impl Into<String>) -> Self
pub fn invalid_signature(reason: impl Into<String>) -> Self
Create an invalid signature error
Sourcepub fn controller_not_leader(leader_id: Option<u64>) -> Self
pub fn controller_not_leader(leader_id: Option<u64>) -> Self
Create a controller not leader error
Examples found in repository?
117fn main() {
118 println!("=== ControllerError Integration Example ===\n");
119
120 // Example 1: Using constructor methods
121 println!("1. Creating controller errors using constructor methods:");
122 let err1 = RocketMQError::controller_not_leader(Some(1));
123 println!(" Not leader: {}", err1);
124
125 let err2 = RocketMQError::controller_timeout(5000);
126 println!(" Timeout: {}", err2);
127
128 let err3 = RocketMQError::controller_invalid_request("missing broker_name");
129 println!(" Invalid request: {}", err3);
130
131 // Example 2: Automatic conversion
132 println!("\n2. Automatic conversion from ControllerError:");
133 let controller_err = ControllerError::Raft("consensus failed".to_string());
134 let rocketmq_err: RocketMQError = controller_err.into();
135 println!(" Converted error: {}", rocketmq_err);
136
137 // Example 3: Error propagation
138 println!("\n3. Error propagation in functions:");
139 match simulated_operation() {
140 Ok(_) => println!(" Operation succeeded"),
141 Err(e) => println!(" Operation failed: {}", e),
142 }
143
144 // Example 4: Pattern matching
145 println!("\n4. Pattern matching on errors:");
146 let errors = vec![
147 RocketMQError::controller_not_leader(Some(2)),
148 RocketMQError::controller_timeout(3000),
149 RocketMQError::controller_shutdown(),
150 ];
151
152 for err in errors {
153 print_error_details(err);
154 }
155
156 println!("\n=== Example completed successfully ===");
157}
158
159// Simulated operation that returns controller error
160fn simulated_operation() -> RocketMQResult<()> {
161 // Simulate a not leader scenario
162 Err(RocketMQError::controller_not_leader(None))
163}Sourcepub fn controller_raft_error(reason: impl Into<String>) -> Self
pub fn controller_raft_error(reason: impl Into<String>) -> Self
Create a controller Raft error
Sourcepub fn controller_metadata_not_found(key: impl Into<String>) -> Self
pub fn controller_metadata_not_found(key: impl Into<String>) -> Self
Create a controller metadata not found error
Sourcepub fn controller_invalid_request(reason: impl Into<String>) -> Self
pub fn controller_invalid_request(reason: impl Into<String>) -> Self
Create a controller invalid request error
Examples found in repository?
117fn main() {
118 println!("=== ControllerError Integration Example ===\n");
119
120 // Example 1: Using constructor methods
121 println!("1. Creating controller errors using constructor methods:");
122 let err1 = RocketMQError::controller_not_leader(Some(1));
123 println!(" Not leader: {}", err1);
124
125 let err2 = RocketMQError::controller_timeout(5000);
126 println!(" Timeout: {}", err2);
127
128 let err3 = RocketMQError::controller_invalid_request("missing broker_name");
129 println!(" Invalid request: {}", err3);
130
131 // Example 2: Automatic conversion
132 println!("\n2. Automatic conversion from ControllerError:");
133 let controller_err = ControllerError::Raft("consensus failed".to_string());
134 let rocketmq_err: RocketMQError = controller_err.into();
135 println!(" Converted error: {}", rocketmq_err);
136
137 // Example 3: Error propagation
138 println!("\n3. Error propagation in functions:");
139 match simulated_operation() {
140 Ok(_) => println!(" Operation succeeded"),
141 Err(e) => println!(" Operation failed: {}", e),
142 }
143
144 // Example 4: Pattern matching
145 println!("\n4. Pattern matching on errors:");
146 let errors = vec![
147 RocketMQError::controller_not_leader(Some(2)),
148 RocketMQError::controller_timeout(3000),
149 RocketMQError::controller_shutdown(),
150 ];
151
152 for err in errors {
153 print_error_details(err);
154 }
155
156 println!("\n=== Example completed successfully ===");
157}Sourcepub fn controller_timeout(timeout_ms: u64) -> Self
pub fn controller_timeout(timeout_ms: u64) -> Self
Create a controller timeout error
Examples found in repository?
117fn main() {
118 println!("=== ControllerError Integration Example ===\n");
119
120 // Example 1: Using constructor methods
121 println!("1. Creating controller errors using constructor methods:");
122 let err1 = RocketMQError::controller_not_leader(Some(1));
123 println!(" Not leader: {}", err1);
124
125 let err2 = RocketMQError::controller_timeout(5000);
126 println!(" Timeout: {}", err2);
127
128 let err3 = RocketMQError::controller_invalid_request("missing broker_name");
129 println!(" Invalid request: {}", err3);
130
131 // Example 2: Automatic conversion
132 println!("\n2. Automatic conversion from ControllerError:");
133 let controller_err = ControllerError::Raft("consensus failed".to_string());
134 let rocketmq_err: RocketMQError = controller_err.into();
135 println!(" Converted error: {}", rocketmq_err);
136
137 // Example 3: Error propagation
138 println!("\n3. Error propagation in functions:");
139 match simulated_operation() {
140 Ok(_) => println!(" Operation succeeded"),
141 Err(e) => println!(" Operation failed: {}", e),
142 }
143
144 // Example 4: Pattern matching
145 println!("\n4. Pattern matching on errors:");
146 let errors = vec![
147 RocketMQError::controller_not_leader(Some(2)),
148 RocketMQError::controller_timeout(3000),
149 RocketMQError::controller_shutdown(),
150 ];
151
152 for err in errors {
153 print_error_details(err);
154 }
155
156 println!("\n=== Example completed successfully ===");
157}Sourcepub fn controller_shutdown() -> Self
pub fn controller_shutdown() -> Self
Create a controller shutdown error
Examples found in repository?
117fn main() {
118 println!("=== ControllerError Integration Example ===\n");
119
120 // Example 1: Using constructor methods
121 println!("1. Creating controller errors using constructor methods:");
122 let err1 = RocketMQError::controller_not_leader(Some(1));
123 println!(" Not leader: {}", err1);
124
125 let err2 = RocketMQError::controller_timeout(5000);
126 println!(" Timeout: {}", err2);
127
128 let err3 = RocketMQError::controller_invalid_request("missing broker_name");
129 println!(" Invalid request: {}", err3);
130
131 // Example 2: Automatic conversion
132 println!("\n2. Automatic conversion from ControllerError:");
133 let controller_err = ControllerError::Raft("consensus failed".to_string());
134 let rocketmq_err: RocketMQError = controller_err.into();
135 println!(" Converted error: {}", rocketmq_err);
136
137 // Example 3: Error propagation
138 println!("\n3. Error propagation in functions:");
139 match simulated_operation() {
140 Ok(_) => println!(" Operation succeeded"),
141 Err(e) => println!(" Operation failed: {}", e),
142 }
143
144 // Example 4: Pattern matching
145 println!("\n4. Pattern matching on errors:");
146 let errors = vec![
147 RocketMQError::controller_not_leader(Some(2)),
148 RocketMQError::controller_timeout(3000),
149 RocketMQError::controller_shutdown(),
150 ];
151
152 for err in errors {
153 print_error_details(err);
154 }
155
156 println!("\n=== Example completed successfully ===");
157}Sourcepub fn filter_empty_bytes() -> Self
pub fn filter_empty_bytes() -> Self
Create an empty bytes error
Sourcepub fn filter_invalid_bit_length() -> Self
pub fn filter_invalid_bit_length() -> Self
Create an invalid bit length error
Sourcepub fn filter_bit_length_too_small() -> Self
pub fn filter_bit_length_too_small() -> Self
Create a bit length too small error
Sourcepub fn filter_bit_position_out_of_bounds(pos: usize, max: usize) -> Self
pub fn filter_bit_position_out_of_bounds(pos: usize, max: usize) -> Self
Create a bit position out of bounds error
Sourcepub fn filter_byte_position_out_of_bounds(pos: usize, max: usize) -> Self
pub fn filter_byte_position_out_of_bounds(pos: usize, max: usize) -> Self
Create a byte position out of bounds error
Sourcepub fn filter_uninitialized() -> Self
pub fn filter_uninitialized() -> Self
Create an uninitialized 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
use the Display impl or to_string()
Source§impl From<AuthError> for RocketMQError
impl From<AuthError> for RocketMQError
Source§impl From<ControllerError> for RocketMQError
impl From<ControllerError> for RocketMQError
Source§fn from(source: ControllerError) -> Self
fn from(source: ControllerError) -> Self
Source§impl From<Error> for RocketMQError
impl From<Error> for RocketMQError
Source§impl From<FilterError> for RocketMQError
impl From<FilterError> for RocketMQError
Source§fn from(source: FilterError) -> Self
fn from(source: FilterError) -> Self
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