Skip to content

Commit

Permalink
chore: use thiserror instead of strum
Browse files Browse the repository at this point in the history
  • Loading branch information
rumenov committed Feb 19, 2024
1 parent 0d7eadd commit deebcd9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
10 changes: 5 additions & 5 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 rs/p2p/state_sync_manager/BUILD.bazel
Expand Up @@ -20,6 +20,7 @@ DEPENDENCIES = [
"@crate_index//:prost",
"@crate_index//:rand",
"@crate_index//:slog",
"@crate_index//:thiserror",
"@crate_index//:tokio",
"@crate_index//:tokio-metrics",
"@crate_index//:tokio-util",
Expand All @@ -39,7 +40,6 @@ DEV_DEPENDENCIES = [

MACRO_DEPENDENCIES = [
"@crate_index//:async-trait",
"@crate_index//:strum_macros",
]

ALIASES = {}
Expand Down
2 changes: 1 addition & 1 deletion rs/p2p/state_sync_manager/Cargo.toml
Expand Up @@ -19,7 +19,7 @@ prometheus = { workspace = true }
prost = { workspace = true }
rand = { workspace = true }
slog = { workspace = true }
strum_macros = { workspace = true }
thiserror = "1.0.57"
tokio = { workspace = true }
tokio-metrics = { workspace = true }
tokio-util = { workspace = true }
Expand Down
10 changes: 7 additions & 3 deletions rs/p2p/state_sync_manager/src/ongoing.rs
Expand Up @@ -29,7 +29,7 @@ use rand::{
rngs::SmallRng,
SeedableRng,
};
use strum_macros::Display;
use thiserror::Error;
use tokio::{
runtime::Handle,
select,
Expand Down Expand Up @@ -356,21 +356,25 @@ impl<T: 'static + Send> OngoingStateSync<T> {
}
}

#[derive(Debug, Clone, Display)]
#[strum(serialize_all = "snake_case")]
#[derive(Debug, Clone, Error)]
pub(crate) enum DownloadChunkError {
/// Request was processed but requested content was not available.
/// This error is permanent.
#[error("no_content")]
NoContent,
/// Download was cancelled.
#[error("cancelled")]
Cancelled,
/// Request was not processed because peer endpoint is overloaded.
/// This error is transient.
#[error("overloaded")]
Overloaded,
/// Request was not processed because of a timeout either on the client side or on the server side.
#[error("timeout")]
Timeout,
/// An unexpected error occurred during the request. Requests to well-behaving peers
/// do not return a RequestError.
#[error("request_error")]
RequestError { chunk_id: ChunkId, err: String },
}

Expand Down

0 comments on commit deebcd9

Please sign in to comment.