Skip to content
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

Merged
merged 15 commits into from
Aug 5, 2024

Conversation

heemankv
Copy link
Contributor

@heemankv heemankv commented Jul 31, 2024

This PR solves #65.

  • This PR introduces thiserror for clearer description and syntax of throwing errors.
  • This PR scopes for Jobs only!
  • Further implementation to overall codebase are to be handled incrementally.
  • This PR depends on PR Tests for DA job #61 and PR Feat : add testing fixtures and a basic test #52 (only after they are merged should this branch be merged to main.)
  • Implementation also removes log::debug! from various places for which thiserror error handling is introduced.
  • Only Errors specific to the Job are handled, general errors are thrown as Other Errors.

@heemankv heemankv self-assigned this Jul 31, 2024
@heemankv heemankv mentioned this pull request Jul 31, 2024
@heemankv heemankv changed the base branch from main to feat/increasing-test-coverage August 2, 2024 07:36
@heemankv heemankv changed the base branch from feat/increasing-test-coverage to tests/da-job August 2, 2024 07:36
@heemankv heemankv added the enhancement New feature or request label Aug 2, 2024
@heemankv heemankv linked an issue Aug 2, 2024 that may be closed by this pull request
crates/orchestrator/src/jobs/da_job/mod.rs Outdated Show resolved Hide resolved
crates/orchestrator/src/jobs/state_update_job/mod.rs Outdated Show resolved Hide resolved
crates/orchestrator/src/queue/job_queue.rs Outdated Show resolved Hide resolved
Copy link
Member

@cchudant cchudant left a 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 :)

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() {
Copy link
Member

@cchudant cchudant Aug 5, 2024

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

Copy link
Member

@cchudant cchudant Aug 5, 2024

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() })?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch !
Applied.

@apoorvsadana apoorvsadana merged commit 519f1d0 into tests/da-job Aug 5, 2024
@heemankv heemankv deleted the update/JobError-using-thisError branch August 5, 2024 17:12
@heemankv heemankv restored the update/JobError-using-thisError branch August 5, 2024 17:13
apoorvsadana added a commit that referenced this pull request Aug 5, 2024
apoorvsadana added a commit that referenced this pull request Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

create custom Job Errors
3 participants