Skip to content

Commit

Permalink
bridge: Derive std::error::Error for plugin-queue's Error type
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte committed Jun 19, 2024
1 parent cb50b53 commit a5eb225
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 27 deletions.
1 change: 1 addition & 0 deletions bridge/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions bridge/svix-bridge-plugin-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ edition = "2021"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
svix-bridge-types = { path = "../svix-bridge-types" }
thiserror = "1.0.61"
tokio = { version = "1", features = ["full"] }
tokio-executor-trait = "2.1"
tokio-reactor-trait = "1.1"
Expand Down
36 changes: 9 additions & 27 deletions bridge/svix-bridge-plugin-queue/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,20 @@
pub use omniqueue::QueueError;
use svix_bridge_types::svix;
use thiserror::Error;

#[derive(Debug, Error)]
pub enum Error {
Json(serde_json::Error),
Queue(QueueError),
Svix(svix::error::Error),
#[error("json error: {0}")]
Json(#[from] serde_json::Error),
#[error("queue error: {0}")]
Queue(#[from] QueueError),
#[error("svix API error: {0}")]
Svix(#[from] svix::error::Error),
#[error("{0}")]
Generic(String),
}
pub type Result<T> = std::result::Result<T, Error>;

impl From<svix::error::Error> for Error {
fn from(value: svix::error::Error) -> Self {
Error::Svix(value)
}
}

impl From<serde_json::Error> for Error {
fn from(value: serde_json::Error) -> Self {
Error::Json(value)
}
}

impl From<QueueError> for Error {
fn from(value: QueueError) -> Self {
Error::Queue(value)
}
}

impl From<String> for Error {
fn from(value: String) -> Self {
Self::Generic(value)
}
}

impl From<Error> for std::io::Error {
fn from(value: Error) -> Self {
match value {
Expand Down

0 comments on commit a5eb225

Please sign in to comment.