-
Notifications
You must be signed in to change notification settings - Fork 16
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
Update/job error using this error #66
Conversation
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.
cool, looks good to me :)
crates/orchestrator/src/jobs/mod.rs
Outdated
fn increment_key_in_metadata( | ||
metadata: &HashMap<String, String>, | ||
key: &str, | ||
) -> Result<HashMap<String, String>, JobError> { | ||
let mut new_metadata = metadata.clone(); | ||
let attempt = get_u64_from_metadata(metadata, key)?; | ||
let incremented_value = attempt.checked_add(1); | ||
if incremented_value.is_none() { |
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.
let Some(incremented_value) = incremented_value else {
return Err(JobError::KeyOutOfBounds { key: key.to_string() }) }
};
to avoid the unwrap just after
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.
or in this case just, incremented_value.ok_or_else(|| JobError::KeyOutOfBounds { key: key.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.
Good catch !
Applied.
This reverts commit 519f1d0.
This PR solves #65.
thiserror
for clearer description and syntax of throwing errors.Jobs
only!log::debug!
from various places for whichthiserror
error handling is introduced.Job
are handled, general errors are thrown asOther Errors
.