mirror of
https://github.com/mikedilger/chorus.git
synced 2026-07-02 07:13:21 +00:00
depend on serde_json
This commit is contained in:
parent
577243789e
commit
bc44aafd2d
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -260,6 +260,7 @@ dependencies = [
|
||||
"rustls-pki-types",
|
||||
"secp256k1 0.29.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"speedy",
|
||||
"tempfile",
|
||||
"textnonce",
|
||||
|
||||
@ -25,6 +25,7 @@ rustls-pki-types= "1.3"
|
||||
rustls-pemfile = "2.1"
|
||||
secp256k1 = { version = "0.29", features = [ "hashes", "global-context", "rand-std" ] }
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
speedy = "0.8"
|
||||
textnonce = "1"
|
||||
tokio = { version = "1", features = [ "full" ] }
|
||||
|
||||
15
src/error.rs
15
src/error.rs
@ -97,6 +97,9 @@ pub enum ChorusError {
|
||||
// Filter is underspecified
|
||||
Scraper,
|
||||
|
||||
// Serde JSON
|
||||
SerdeJson(serde_json::Error),
|
||||
|
||||
// Speedy
|
||||
Speedy(speedy::Error),
|
||||
|
||||
@ -144,6 +147,7 @@ impl std::fmt::Display for ChorusError {
|
||||
ChorusError::TimedOut => write!(f, "Timed out"),
|
||||
ChorusError::Tungstenite(e) => write!(f, "{e}"),
|
||||
ChorusError::Scraper => write!(f, "Filter is underspecified. Scrapers are not allowed"),
|
||||
ChorusError::SerdeJson(e) => write!(f, "{e}"),
|
||||
ChorusError::Speedy(e) => write!(f, "{e}"),
|
||||
ChorusError::TooManySubscriptions => write!(f, "Too many subscriptions"),
|
||||
ChorusError::UrlParse(e) => write!(f, "{e}"),
|
||||
@ -206,6 +210,7 @@ impl ChorusError {
|
||||
ChorusError::TimedOut => 0.1,
|
||||
ChorusError::Tungstenite(_) => 0.0,
|
||||
ChorusError::Scraper => 0.4,
|
||||
ChorusError::SerdeJson(_) => 0.0,
|
||||
ChorusError::Speedy(_) => 0.0,
|
||||
ChorusError::TooManySubscriptions => 0.1,
|
||||
ChorusError::UrlParse(_) => 0.1,
|
||||
@ -392,3 +397,13 @@ impl From<speedy::Error> for Error {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<serde_json::Error> for Error {
|
||||
#[track_caller]
|
||||
fn from(err: serde_json::Error) -> Self {
|
||||
Error {
|
||||
inner: ChorusError::SerdeJson(err),
|
||||
location: std::panic::Location::caller(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user