Skip to content

Commit 73a548a

Browse files
committed
bridge: Derive std::error::Error for plugin-queue's Error type
1 parent a19c6f6 commit 73a548a

File tree

3 files changed

+11
-27
lines changed

3 files changed

+11
-27
lines changed

bridge/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bridge/svix-bridge-plugin-queue/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ edition = "2021"
99
serde_json = "1.0"
1010
serde = { version = "1.0", features = ["derive"] }
1111
svix-bridge-types = { path = "../svix-bridge-types" }
12+
thiserror = "1.0.61"
1213
tokio = { version = "1", features = ["full"] }
1314
tokio-executor-trait = "2.1"
1415
tokio-reactor-trait = "1.1"

bridge/svix-bridge-plugin-queue/src/error.rs

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,20 @@
11
pub use omniqueue::QueueError;
22
use svix_bridge_types::svix;
3+
use thiserror::Error;
34

5+
#[derive(Debug, Error)]
46
pub enum Error {
5-
Json(serde_json::Error),
6-
Queue(QueueError),
7-
Svix(svix::error::Error),
7+
#[error("json error: {0}")]
8+
Json(#[from] serde_json::Error),
9+
#[error("queue error: {0}")]
10+
Queue(#[from] QueueError),
11+
#[error("svix API error: {0}")]
12+
Svix(#[from] svix::error::Error),
13+
#[error("{0}")]
814
Generic(String),
915
}
1016
pub type Result<T> = std::result::Result<T, Error>;
1117

12-
impl From<svix::error::Error> for Error {
13-
fn from(value: svix::error::Error) -> Self {
14-
Error::Svix(value)
15-
}
16-
}
17-
18-
impl From<serde_json::Error> for Error {
19-
fn from(value: serde_json::Error) -> Self {
20-
Error::Json(value)
21-
}
22-
}
23-
24-
impl From<QueueError> for Error {
25-
fn from(value: QueueError) -> Self {
26-
Error::Queue(value)
27-
}
28-
}
29-
30-
impl From<String> for Error {
31-
fn from(value: String) -> Self {
32-
Self::Generic(value)
33-
}
34-
}
35-
3618
impl From<Error> for std::io::Error {
3719
fn from(value: Error) -> Self {
3820
match value {

0 commit comments

Comments
 (0)