-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(commands): add lossy flag when creating annotations #289
Conversation
|
||
#[structopt(long)] | ||
/// Whether to attempt to resume processing on error | ||
lossy: bool, |
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.
lossy
isn't very descriptive. How about resume-on-error
?
format!( | ||
"{} {}{}", | ||
num_annotations, | ||
"annotations".dimmed(), | ||
if num_failed_annotations > 0 { | ||
format!(" {} {}", num_failed_annotations, "skipped".dimmed()) | ||
} else { | ||
"".to_string() | ||
} | ||
), |
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.
The nested format!
is a bit cheeky. How about:
let failed_annotations_string = if num_failed_annotations > 0 {
format!(" {num_failed_annotations} {}", "skipped".dimmed())
} else {
String::new()
};
Similarly below.
cli/src/main.rs
Outdated
pub fn print_error_as_warning(error: &anyhow::Error) { | ||
warn!("An error occurred. Resuming..."); | ||
for cause in error.chain() { | ||
warn!(" |- {}", cause); | ||
} | ||
} | ||
|
||
pub fn print_error(error: &anyhow::Error) { | ||
error!("An error occurred:"); | ||
for cause in error.chain() { | ||
error!(" |- {}", cause); | ||
} | ||
} |
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.
We shouldn't need two functions. How about just
pub fn print_error(error: &anyhow::Error) {
for cause in error.chain() {
error!(" |- {}", cause);
}
}
and leave the call to error!()
before it in main()
below. You can add the call to warn!()
in upload_batch_of_annotations()
, but I'm not sure logging in that case is necessary.
Adding a flag to attempt to resume processing when operations fail. Starting with annotations but could later be used for comments also