Skip to content

Commit

Permalink
feat: Enable converting roadster::Error to sidekiq::Error (#514)
Browse files Browse the repository at this point in the history
Add `From` impl to allow converting a `roadster::Error` into a
`sidekiq::Error`. This makes writing worker code more ergonomic.

Closes #488
  • Loading branch information
spencewenski authored Nov 17, 2024
1 parent 3f0296b commit 4e91186
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/error/sidekiq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,21 @@ impl From<bb8::RunError<sidekiq::RedisError>> for Error {
Self::Sidekiq(SidekiqError::from(value))
}
}

impl From<Error> for sidekiq::Error {
fn from(value: Error) -> Self {
match value {
Error::Sidekiq(err) => err.into(),
_ => sidekiq::Error::Any(Box::new(value)),
}
}
}

impl From<SidekiqError> for sidekiq::Error {
fn from(value: SidekiqError) -> Self {
match value {
SidekiqError::Sidekiq(err) => err,
_ => sidekiq::Error::Any(Box::new(value)),
}
}
}

0 comments on commit 4e91186

Please sign in to comment.