Skip to content

Commit 67d3ce8

Browse files
Merge pull request #159 from influxdata/crepererum/errors_non_exhaustive
refactor: make errors non-exhaustive
2 parents b13689f + 02c9677 commit 67d3ce8

File tree

8 files changed

+12
-0
lines changed

8 files changed

+12
-0
lines changed

src/client/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ pub use crate::messenger::RequestError;
44
pub use crate::protocol::error::Error as ProtocolError;
55

66
#[derive(Error, Debug)]
7+
#[non_exhaustive]
78
pub enum Error {
89
#[error("Connection error: {0}")]
910
Connection(#[from] crate::connection::Error),

src/connection.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub type BrokerConnection = Arc<MessengerTransport>;
2323
pub type MessengerTransport = Messenger<BufStream<transport::Transport>>;
2424

2525
#[derive(Debug, Error)]
26+
#[non_exhaustive]
2627
pub enum Error {
2728
#[error("error getting cluster metadata: {0}")]
2829
Metadata(#[from] RequestError),

src/connection/transport.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub type TlsConfig = Option<Arc<rustls::ClientConfig>>;
1717
pub type TlsConfig = ();
1818

1919
#[derive(Debug, Error)]
20+
#[non_exhaustive]
2021
pub enum Error {
2122
#[error("IO Error: {0}")]
2223
IO(#[from] std::io::Error),

src/messenger.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ pub struct Messenger<RW> {
117117
}
118118

119119
#[derive(Error, Debug)]
120+
#[non_exhaustive]
120121
pub enum RequestError {
121122
#[error("Cannot find matching version for: {api_key:?}")]
122123
NoVersionMatch { api_key: ApiKey },
@@ -154,6 +155,7 @@ pub enum RequestError {
154155
}
155156

156157
#[derive(Error, Debug)]
158+
#[non_exhaustive]
157159
pub enum SyncVersionsError {
158160
#[error("Did not found a version for ApiVersion that works with that broker")]
159161
NoWorkingVersion,

src/protocol/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use super::primitives::Int16;
77

88
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
99
#[allow(clippy::enum_variant_names)]
10+
#[non_exhaustive]
1011
pub enum Error {
1112
UnknownServerError,
1213
OffsetOutOfRange,

src/protocol/frame.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use super::{
1515
};
1616

1717
#[derive(Error, Debug)]
18+
#[non_exhaustive]
1819
pub enum ReadError {
1920
#[error("Cannot read data: {0}")]
2021
IO(#[from] std::io::Error),
@@ -74,6 +75,7 @@ where
7475
}
7576

7677
#[derive(Error, Debug)]
78+
#[non_exhaustive]
7779
pub enum WriteError {
7880
#[error("Cannot write data: {0}")]
7981
IO(#[from] std::io::Error),

src/protocol/messages/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ pub use produce::*;
3838
mod test_utils;
3939

4040
#[derive(Error, Debug)]
41+
#[non_exhaustive]
4142
pub enum ReadVersionedError {
4243
#[error("Read error: {0}")]
4344
ReadError(#[from] ReadError),
@@ -51,6 +52,7 @@ where
5152
}
5253

5354
#[derive(Error, Debug)]
55+
#[non_exhaustive]
5456
pub enum WriteVersionedError {
5557
#[error("Write error: {0}")]
5658
WriteError(#[from] WriteError),

src/protocol/traits.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::io::{Read, Write};
33
use thiserror::Error;
44

55
#[derive(Error, Debug)]
6+
#[non_exhaustive]
67
pub enum ReadError {
78
#[error("Cannot read data: {0}")]
89
IO(#[from] std::io::Error),
@@ -22,6 +23,7 @@ where
2223
}
2324

2425
#[derive(Error, Debug)]
26+
#[non_exhaustive]
2527
pub enum WriteError {
2628
#[error("Cannot write data: {0}")]
2729
IO(#[from] std::io::Error),

0 commit comments

Comments
 (0)