-
Notifications
You must be signed in to change notification settings - Fork 71
Include latest error in AllAttemptsErrored #188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
ValuedMammal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, however you still have unwrap in your code which isn't great. Maybe it will be better to log the warning first before placing the error into the errors vec.
9d4d4aa to
59c28bd
Compare
|
Updated, how's about now?
|
|
In 59c28bd: I understand that we can expect Please also include a PR description that others can make sense of, and consider using conventional commits. Thanks for your contribution. @nabijaczleweli |
|
Sure, whatever; applied. You're free to rephrase the PR and commit descriptions as you see fit, from my POV "Include latest error in AllAttemptsErrored" follows all the relevant conventions and is human-readable. |
|
I had an additional comment related to the order of the logging statements. I think I would prefer this way, so that in the case of a failed attempt the latest error --- a/src/client.rs
+++ b/src/client.rs
@@ -55,16 +55,15 @@ macro_rules! impl_inner_call {
Err(e) => {
let failed_attempts = errors.len() + 1;
+ warn!("call '{}' failed with {}, retry: {}/{}", stringify!($name), e, failed_attempts, $self.config.retry());
+
+ errors.push(e);
+
if retries_exhausted(failed_attempts, $self.config.retry()) {
warn!("call '{}' failed after {} attempts", stringify!($name), failed_attempts);
- errors.push(e);
return Err(Error::AllAttemptsErrored(errors));
}
- warn!("call '{}' failed with {}, retry: {}/{}", stringify!($name), e, failed_attempts, $self.config.retry());
-
- errors.push(e);
-
// Only one thread will try to recreate the client getting the write lock,
// other eventual threads will get Err and will block at the beginning of
// previous loop when trying to read()
@@ -80,15 +79,14 @@ macro_rules! impl_inner_call {
Err(e) => {
let failed_attempts = errors.len() + 1;
+ warn!("re-creating client failed with {}, retry: {}/{}", e, failed_attempts, $self.config.retry());
+
+ errors.push(e);
+
if retries_exhausted(failed_attempts, $self.config.retry()) {
warn!("re-creating client failed after {} attempts", failed_attempts);
- errors.push(e);
return Err(Error::AllAttemptsErrored(errors));
}
-
- warn!("re-creating client failed with {}, retry: {}/{}", e, failed_attempts, $self.config.retry());
-
- errors.push(e);
}
}
} |
$ git grep AllAttemptsErrored
src/client.rs: return Err(Error::AllAttemptsErrored(errors));
src/client.rs: return Err(Error::AllAttemptsErrored(errors));
fixed here
src/raw_client.rs: Err(Error::AllAttemptsErrored(errors))
already correctly collected
src/types.rs: AllAttemptsErrored(Vec<Error>),
src/types.rs: Error::AllAttemptsErrored(errors) => {
consumers
This also reorders the warning before the error:
warn!("re-creating client failed with {}, retry: {}/{}", e, failed_attempts, $self.config.retry());
warn!("re-creating client failed after {} attempts", failed_attempts);
Closes bitcoindevkit#186
|
I think this is a functional change (which I naturally wouldn't do unless otherwise directed), but I do prefer this order. Applied. |
fixed here
already correctly collected
consumers
Closes #186