-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract error sorting code to module. (#1077)
* Extract error sorting code to module. This will allow FFI clients to use the same logic. * ++redis-rs * fix comments.
- Loading branch information
Showing
9 changed files
with
64 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright GLIDE-for-Redis Project Contributors - SPDX Identifier: Apache-2.0 | ||
*/ | ||
|
||
use redis::RedisError; | ||
|
||
#[repr(C)] | ||
pub enum RequestErrorType { | ||
Unspecified = 0, | ||
ExecAbort = 1, | ||
Timeout = 2, | ||
Disconnect = 3, | ||
} | ||
|
||
pub fn error_type(error: &RedisError) -> RequestErrorType { | ||
if error.is_timeout() { | ||
RequestErrorType::Timeout | ||
} else if error.is_unrecoverable_error() { | ||
RequestErrorType::Disconnect | ||
} else if matches!(error.kind(), redis::ErrorKind::ExecAbortError) { | ||
RequestErrorType::ExecAbort | ||
} else { | ||
RequestErrorType::Unspecified | ||
} | ||
} | ||
|
||
pub fn error_message(error: &RedisError) -> String { | ||
let error_message = error.to_string(); | ||
if matches!(error_type(error), RequestErrorType::Disconnect) { | ||
format!("Received connection error `{error_message}`. Will attempt to reconnect") | ||
} else { | ||
error_message | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule redis-rs
updated
40 files