Skip to content

Commit

Permalink
Change error types back to tuples (#762)
Browse files Browse the repository at this point in the history
* Change error types back to tuples

* Bump all crates with breaking changes from errors
  • Loading branch information
nicholastmosher authored Feb 9, 2021
1 parent 073a9e5 commit 63202b9
Show file tree
Hide file tree
Showing 19 changed files with 35 additions and 85 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/auth/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fluvio-controlplane-metadata = { version = "0.6.0", path = "../controlplane-meta
dataplane = { version = "0.3.0", path = "../dataplane-protocol", package = "fluvio-dataplane-protocol" }
fluvio-future = { version = "0.1.12", features = ["net", "openssl_tls"] }
fluvio-protocol = { path = "../protocol", version = "0.3.0" }
fluvio-socket = { path = "../socket", version = "0.5.0" }
fluvio-socket = { path = "../socket", version = "0.6.0" }
fluvio-types = { version = "0.2.0", path = "../types" }
flv-tls-proxy = { version = "0.3.0" }
futures-util = { version = "0.3.5" }
Expand Down
7 changes: 2 additions & 5 deletions src/auth/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@ use thiserror::Error;
#[derive(Error, Debug)]
pub enum AuthError {
#[error("IoError")]
IoError {
#[from]
source: IoError,
},
IoError(#[from] IoError),
}

impl Into<IoError> for AuthError {
fn into(self) -> IoError {
match self {
Self::IoError { source } => source,
Self::IoError(source) => source,
}
}
}
2 changes: 1 addition & 1 deletion src/auth/src/x509/authenticator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl X509Authenticator {
.send(&request_message)
.await
.map_err(|err| match err {
fluvio_socket::FlvSocketError::IoError { source } => source,
fluvio_socket::FlvSocketError::IoError(source) => source,
fluvio_socket::FlvSocketError::SocketClosed => {
IoError::new(IoErrorKind::BrokenPipe, "connection closed")
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ fluvio-future = { version = "0.1.8", features = ["fs", "io", "subscriber"] }
fluvio = { version = "0.5.0", path = "../client", default-features = false }
fluvio-cluster = { version = "0.7.0", path = "../cluster", default-features = false, features = ["cli"] }
fluvio-package-index = { version = "0.2.0", path = "../package-index" }
fluvio-extension-consumer = { version = "0.2.0", path = "../extension-consumer" }
fluvio-extension-common = { version = "0.2.0", path = "../extension-common", features = ["target"]}
fluvio-extension-consumer = { version = "0.3.0", path = "../extension-consumer" }
fluvio-controlplane-metadata = { version = "0.6.0", path = "../controlplane-metadata", features = ["use_serde", "k8"] }
k8-types = { version = "0.1.0", features = ["core"]}

Expand Down
2 changes: 1 addition & 1 deletion src/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fluvio-future = { version = "0.1.15", features = ["task", "native2_tls"] }
fluvio-types = { version = "0.2.0", path = "../types" }
fluvio-sc-schema = { version = "0.6.0", path = "../sc-schema", default-features = false }
fluvio-spu-schema = { version = "0.4.0", path = "../spu-schema" }
fluvio-socket = { path = "../socket", version = "0.5.0", features = ["tls"] }
fluvio-socket = { path = "../socket", version = "0.6.0", features = ["tls"] }
fluvio-protocol = { path = "../protocol", version = "0.3.0" }
dataplane = { version = "0.3.0", path = "../dataplane-protocol", package = "fluvio-dataplane-protocol" }

Expand Down
24 changes: 7 additions & 17 deletions src/client/src/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,9 @@ use crate::{FluvioConfig, FluvioError};
#[derive(Error, Debug)]
pub enum ConfigError {
#[error(transparent)]
ConfigFileError {
#[from]
source: IoError,
},
ConfigFileError(#[from] IoError),
#[error("Failed to deserialize Fluvio config")]
TomlError {
#[from]
source: toml::de::Error,
},
TomlError(#[from] toml::de::Error),
#[error("Config has no active profile")]
NoActiveProfile,
#[error("No cluster config for profile {profile}")]
Expand Down Expand Up @@ -73,18 +67,15 @@ impl ConfigFile {

/// try to load from default locations
pub fn load(optional_path: Option<String>) -> Result<Self, FluvioError> {
let path = Self::default_file_path(optional_path)
.map_err(|source| ConfigError::ConfigFileError { source })?;
let path = Self::default_file_path(optional_path).map_err(ConfigError::ConfigFileError)?;
Self::from_file(path)
}

/// read from file
fn from_file<T: AsRef<Path>>(path: T) -> Result<Self, FluvioError> {
let path_ref = path.as_ref();
let file_str: String =
read_to_string(path_ref).map_err(|source| ConfigError::ConfigFileError { source })?;
let config =
toml::from_str(&file_str).map_err(|source| ConfigError::TomlError { source })?;
let file_str: String = read_to_string(path_ref).map_err(ConfigError::ConfigFileError)?;
let config = toml::from_str(&file_str).map_err(ConfigError::TomlError)?;
Ok(Self::new(path_ref.to_owned(), config))
}

Expand Down Expand Up @@ -123,11 +114,10 @@ impl ConfigFile {

// save to file
pub fn save(&self) -> Result<(), FluvioError> {
create_dir_all(self.path.parent().unwrap())
.map_err(|source| ConfigError::ConfigFileError { source })?;
create_dir_all(self.path.parent().unwrap()).map_err(ConfigError::ConfigFileError)?;
self.config
.save_to(&self.path)
.map_err(|source| ConfigError::ConfigFileError { source })?;
.map_err(ConfigError::ConfigFileError)?;
Ok(())
}
}
Expand Down
20 changes: 4 additions & 16 deletions src/client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,13 @@ pub enum FluvioError {
#[error("Spu not found: {0}")]
SPUNotFound(i32),
#[error(transparent)]
IoError {
#[from]
source: IoError,
},
IoError(#[from] IoError),
#[error("Fluvio socket error")]
FlvSocketError {
#[from]
source: FlvSocketError,
},
FlvSocketError(#[from] FlvSocketError),
#[error("Fluvio SC schema error")]
ApiError {
#[from]
source: ApiError,
},
ApiError(#[from] ApiError),
#[error("Fluvio config error")]
ConfigError {
#[from]
source: ConfigError,
},
ConfigError(#[from] ConfigError),
#[error("Attempted to create negative offset: {0}")]
NegativeOffset(i64),
#[error("Cluster (with platform version {cluster_version}) is older than the minimum required version {client_minimum_version}")]
Expand Down
2 changes: 1 addition & 1 deletion src/dataplane-protocol/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ fluvio-protocol = { path = "../protocol", version = "0.3.0", features = ["derive
flv-util = { version = "0.5.0" }

[dev-dependencies]
fluvio-socket = { path = "../socket", version = "0.5.0" }
fluvio-socket = { path = "../socket", version = "0.6.0" }
fluvio-future = { version = "0.1.0", features = ["fixture","fs"] }
flv-util = { version = "0.5.2", features = ["fixture"] }
10 changes: 2 additions & 8 deletions src/extension-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,9 @@ pub mod target {
#[derive(thiserror::Error, Debug)]
pub enum TargetError {
#[error(transparent)]
IoError {
#[from]
source: IoError,
},
IoError(#[from] IoError),
#[error("Fluvio client error")]
ClientError {
#[from]
source: FluvioError,
},
ClientError(#[from] FluvioError),
#[error("Invalid argument: {0}")]
InvalidArg(String),
#[error("Unknown error: {0}")]
Expand Down
2 changes: 1 addition & 1 deletion src/extension-consumer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fluvio-extension-consumer"
version = "0.2.0"
version = "0.3.0"
edition = "2018"
authors = ["Fluvio Contributors <[email protected]>"]
description = "Fluvio consumer extension"
Expand Down
20 changes: 4 additions & 16 deletions src/extension-consumer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,15 @@ pub type Result<T> = std::result::Result<T, ConsumerError>;
#[derive(thiserror::Error, Debug)]
pub enum ConsumerError {
#[error(transparent)]
IoError {
#[from]
source: IoError,
},
IoError(#[from] IoError),
#[error(transparent)]
OutputError {
#[from]
source: OutputError,
},
OutputError(#[from] OutputError),
#[error("Fluvio client error")]
ClientError {
#[from]
source: FluvioError,
},
ClientError(#[from] FluvioError),
#[error("Invalid argument: {0}")]
InvalidArg(String),
#[error("Error finding executable")]
WhichError {
#[from]
source: which::Error,
},
WhichError(#[from] which::Error),
#[error("Unknown error: {0}")]
Other(String),
}
Expand Down
2 changes: 1 addition & 1 deletion src/sc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ k8-metadata-client = { version = "3.0.0" }
k8-types = { version = "0.1.0", features = ["app"]}
fluvio-protocol = { path = "../protocol", version = "0.3.0" }
dataplane = { version = "0.3.0", path = "../dataplane-protocol", package = "fluvio-dataplane-protocol" }
fluvio-socket = { path = "../socket", version = "0.5.0" }
fluvio-socket = { path = "../socket", version = "0.6.0" }
fluvio-service = { path = "../service", version = "0.4.0" }
flv-tls-proxy = { version = "0.3.0" }

Expand Down
2 changes: 1 addition & 1 deletion src/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ tokio = { version = "0.2.21", features = ["macros"] }
# Fluvio dependencies
futures-util = { version = "0.3.5" }
fluvio-future = { version = "0.1.0" }
fluvio-socket = { version = "0.5.0", path = "../socket" }
fluvio-socket = { version = "0.6.0", path = "../socket" }
fluvio-protocol = { path = "../protocol", version = "0.3.0", features = ["derive", "api", "codec"] }


Expand Down
2 changes: 1 addition & 1 deletion src/socket/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fluvio-socket"
version = "0.5.1"
version = "0.6.0"
edition = "2018"
authors = ["Fluvio Contributors <[email protected]>"]
description = "Provide TCP socket wrapper for fluvio protocol"
Expand Down
11 changes: 2 additions & 9 deletions src/socket/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@ use thiserror::Error;
#[derive(Error, Debug)]
pub enum FlvSocketError {
#[error(transparent)]
IoError {
#[from]
source: IoError,
},
IoError(#[from] IoError),
#[error("Socket closed")]
SocketClosed,

#[error("Zero-copy IO error")]
SendFileError {
#[from]
source: SendFileError,
},
SendFileError(#[from] SendFileError),
}
2 changes: 1 addition & 1 deletion src/socket/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
}
Err(source) => {
error!("error receiving response: {:?}", source);
Err(FlvSocketError::IoError { source })
Err(FlvSocketError::IoError(source))
}
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/spu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ fluvio-controlplane-metadata = { version = "0.6.0", path = "../controlplane-meta
fluvio-spu-schema = { version = "0.4.0", path = "../spu-schema" }
fluvio-protocol = { path = "../protocol", version = "0.3.0" }
dataplane = { version = "0.3.0", path = "../dataplane-protocol", package = "fluvio-dataplane-protocol" }
fluvio-socket = { path = "../socket", version = "0.5.0" }
fluvio-socket = { path = "../socket", version = "0.6.0" }
fluvio-service = { path = "../service", version = "0.4.0" }
flv-tls-proxy = { version = "0.3.0" }
flv-util = { version = "0.5.0" }
Expand Down
2 changes: 1 addition & 1 deletion src/storage/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ async-mutex = "1.4.0"
[dev-dependencies]
fluvio-future = { version = "0.1.8", features = ["fixture"] }
flv-util = { version = "0.5.2", features = ["fixture"] }
fluvio-socket = { path = "../socket", version = "0.5.0" }
fluvio-socket = { path = "../socket", version = "0.6.0" }

0 comments on commit 63202b9

Please sign in to comment.