Skip to content

Commit

Permalink
Convert RedisError into nativelink Error
Browse files Browse the repository at this point in the history
Adds the ability to convert a RedisError into a Nativelink Error.
This will dramatically simplifies error handling when dealing with
errors returned by the new redis backend for the scheduler.
  • Loading branch information
zbirenbaum committed Jun 4, 2024
1 parent 8b94236 commit 2beda61
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions nativelink-error/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rust_library(
"@crates//:hex",
"@crates//:prost",
"@crates//:prost-types",
"@crates//:redis",
"@crates//:tokio",
"@crates//:tonic",
],
Expand Down
1 change: 1 addition & 0 deletions nativelink-error/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ nativelink-proto = { path = "../nativelink-proto" }
hex = "0.4.3"
prost = "0.12.4"
prost-types = "0.12.4"
redis = "0.25.2"
tokio = { version = "1.37.0" }
tonic = { version = "0.11.0", features = ["gzip"] }
6 changes: 6 additions & 0 deletions nativelink-error/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ impl From<std::io::Error> for Error {
}
}

impl From<redis::RedisError> for Error {
fn from(err: redis::RedisError) -> Self {
make_err!(Code::Internal, "{}", err.to_string())
}
}

impl From<Code> for Error {
fn from(code: Code) -> Self {
make_err!(code, "")
Expand Down

0 comments on commit 2beda61

Please sign in to comment.