1#[derive(serde::Serialize, serde::Deserialize)]
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct ErrorMetadata {
5 #[prost(uint64, optional, tag = "1")]
7 pub retry_after_ms: ::core::option::Option<u64>,
8 #[prost(string, optional, tag = "2")]
10 pub leader_id: ::core::option::Option<::prost::alloc::string::String>,
11 #[prost(string, optional, tag = "3")]
12 pub leader_address: ::core::option::Option<::prost::alloc::string::String>,
13 #[prost(string, optional, tag = "15")]
15 pub debug_message: ::core::option::Option<::prost::alloc::string::String>,
16}
17#[derive(serde::Serialize, serde::Deserialize)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
19#[repr(i32)]
20pub enum ErrorCode {
21 Success = 0,
23 ConnectionTimeout = 1001,
27 InvalidAddress = 1002,
28 LeaderChanged = 1003,
29 JoinError = 1004,
30 InvalidResponse = 2001,
34 VersionMismatch = 2002,
35 DiskFull = 3001,
39 DataCorruption = 3002,
40 StorageIoError = 3003,
41 StoragePermissionDenied = 3004,
42 KeyNotExist = 3005,
43 NotLeader = 4001,
47 StaleOperation = 4002,
48 InvalidRequest = 4003,
49 RateLimited = 4004,
50 ClusterUnavailable = 4005,
51 ProposeFailed = 4006,
52 TermOutdated = 4007,
53 RetryRequired = 4008,
54 General = 8888,
58 Uncategorized = 9999,
59}
60impl ErrorCode {
61 pub fn as_str_name(&self) -> &'static str {
66 match self {
67 Self::Success => "SUCCESS",
68 Self::ConnectionTimeout => "CONNECTION_TIMEOUT",
69 Self::InvalidAddress => "INVALID_ADDRESS",
70 Self::LeaderChanged => "LEADER_CHANGED",
71 Self::JoinError => "JOIN_ERROR",
72 Self::InvalidResponse => "INVALID_RESPONSE",
73 Self::VersionMismatch => "VERSION_MISMATCH",
74 Self::DiskFull => "DISK_FULL",
75 Self::DataCorruption => "DATA_CORRUPTION",
76 Self::StorageIoError => "STORAGE_IO_ERROR",
77 Self::StoragePermissionDenied => "STORAGE_PERMISSION_DENIED",
78 Self::KeyNotExist => "KEY_NOT_EXIST",
79 Self::NotLeader => "NOT_LEADER",
80 Self::StaleOperation => "STALE_OPERATION",
81 Self::InvalidRequest => "INVALID_REQUEST",
82 Self::RateLimited => "RATE_LIMITED",
83 Self::ClusterUnavailable => "CLUSTER_UNAVAILABLE",
84 Self::ProposeFailed => "PROPOSE_FAILED",
85 Self::TermOutdated => "TERM_OUTDATED",
86 Self::RetryRequired => "RETRY_REQUIRED",
87 Self::General => "GENERAL",
88 Self::Uncategorized => "UNCATEGORIZED",
89 }
90 }
91 pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
93 match value {
94 "SUCCESS" => Some(Self::Success),
95 "CONNECTION_TIMEOUT" => Some(Self::ConnectionTimeout),
96 "INVALID_ADDRESS" => Some(Self::InvalidAddress),
97 "LEADER_CHANGED" => Some(Self::LeaderChanged),
98 "JOIN_ERROR" => Some(Self::JoinError),
99 "INVALID_RESPONSE" => Some(Self::InvalidResponse),
100 "VERSION_MISMATCH" => Some(Self::VersionMismatch),
101 "DISK_FULL" => Some(Self::DiskFull),
102 "DATA_CORRUPTION" => Some(Self::DataCorruption),
103 "STORAGE_IO_ERROR" => Some(Self::StorageIoError),
104 "STORAGE_PERMISSION_DENIED" => Some(Self::StoragePermissionDenied),
105 "KEY_NOT_EXIST" => Some(Self::KeyNotExist),
106 "NOT_LEADER" => Some(Self::NotLeader),
107 "STALE_OPERATION" => Some(Self::StaleOperation),
108 "INVALID_REQUEST" => Some(Self::InvalidRequest),
109 "RATE_LIMITED" => Some(Self::RateLimited),
110 "CLUSTER_UNAVAILABLE" => Some(Self::ClusterUnavailable),
111 "PROPOSE_FAILED" => Some(Self::ProposeFailed),
112 "TERM_OUTDATED" => Some(Self::TermOutdated),
113 "RETRY_REQUIRED" => Some(Self::RetryRequired),
114 "GENERAL" => Some(Self::General),
115 "UNCATEGORIZED" => Some(Self::Uncategorized),
116 _ => None,
117 }
118 }
119}