mirror of
https://github.com/mikedilger/chorus.git
synced 2026-05-03 06:51:42 +00:00
3 new error variants needed for blossom work
This commit is contained in:
parent
d526f103c7
commit
28fb96a9d5
30
src/error.rs
30
src/error.rs
@ -23,7 +23,7 @@ impl std::fmt::Display for Error {
|
||||
/// Errors that can occur in the chorus crate
|
||||
#[derive(Debug)]
|
||||
pub enum ChorusError {
|
||||
// Auth failure
|
||||
// Nostr AUTH failure
|
||||
AuthFailure(String),
|
||||
|
||||
// Auth required
|
||||
@ -50,6 +50,9 @@ pub enum ChorusError {
|
||||
// Blocked IP
|
||||
BlockedIp,
|
||||
|
||||
// Blossom Authorization failure
|
||||
BlossomAuthFailure(String),
|
||||
|
||||
// Channel Recv
|
||||
ChannelRecv(tokio::sync::broadcast::error::RecvError),
|
||||
|
||||
@ -101,6 +104,9 @@ pub enum ChorusError {
|
||||
// Missing Table
|
||||
MissingTable(&'static str),
|
||||
|
||||
// Non-ASCII HTTP header value
|
||||
NonAsciiHttpHeaderValue(http::header::ToStrError),
|
||||
|
||||
// No private key
|
||||
NoPrivateKey,
|
||||
|
||||
@ -140,6 +146,9 @@ pub enum ChorusError {
|
||||
// Serde JSON
|
||||
SerdeJson(serde_json::Error),
|
||||
|
||||
// Signal - Not Blossom Request
|
||||
SignalNotBlossom,
|
||||
|
||||
// Speedy
|
||||
Speedy(speedy::Error),
|
||||
|
||||
@ -179,6 +188,7 @@ impl std::fmt::Display for ChorusError {
|
||||
ChorusError::BannedUser => write!(f, "User is banned"),
|
||||
ChorusError::Base64Decode(e) => write!(f, "{e}"),
|
||||
ChorusError::BlockedIp => write!(f, "IP is temporarily blocked"),
|
||||
ChorusError::BlossomAuthFailure(s) => write!(f, "Authorization failure: {s}"),
|
||||
ChorusError::ChannelRecv(e) => write!(f, "{e}"),
|
||||
ChorusError::ChannelSend(e) => write!(f, "{e}"),
|
||||
ChorusError::Config(e) => write!(f, "{e}"),
|
||||
@ -196,6 +206,9 @@ impl std::fmt::Display for ChorusError {
|
||||
ChorusError::Io(e) => write!(f, "{e}"),
|
||||
ChorusError::ManagementAuthFailure(s) => write!(f, "Authorization failure: {s}"),
|
||||
ChorusError::MissingTable(t) => write!(f, "Missing table: {t}"),
|
||||
ChorusError::NonAsciiHttpHeaderValue(e) => {
|
||||
write!(f, "Non ASCII HTTP header value: {e}")
|
||||
}
|
||||
ChorusError::NoPrivateKey => write!(f, "Private Key Not Found"),
|
||||
ChorusError::NotImplemented => write!(f, "Not implemented"),
|
||||
ChorusError::NoSuchSubscription => write!(f, "No such subscription"),
|
||||
@ -209,6 +222,7 @@ impl std::fmt::Display for ChorusError {
|
||||
ChorusError::Rustls(e) => write!(f, "{e}"),
|
||||
ChorusError::Scraper => write!(f, "Filter is underspecified. Scrapers are not allowed"),
|
||||
ChorusError::SerdeJson(e) => write!(f, "{e}"),
|
||||
ChorusError::SignalNotBlossom => write!(f, "internal-signal-not-blossom"),
|
||||
ChorusError::Speedy(e) => write!(f, "{e}"),
|
||||
ChorusError::TimedOut => write!(f, "Timed out"),
|
||||
ChorusError::TooManySubscriptions => write!(f, "Too many subscriptions"),
|
||||
@ -236,6 +250,7 @@ impl StdError for ChorusError {
|
||||
ChorusError::InvalidUri(e) => Some(e),
|
||||
ChorusError::InvalidUriParts(e) => Some(e),
|
||||
ChorusError::Io(e) => Some(e),
|
||||
ChorusError::NonAsciiHttpHeaderValue(e) => Some(e),
|
||||
ChorusError::PocketDb(e) => Some(e),
|
||||
ChorusError::PocketDbHeed(e) => Some(e),
|
||||
ChorusError::PocketType(e) => Some(e),
|
||||
@ -271,6 +286,7 @@ impl ChorusError {
|
||||
ChorusError::BannedUser => 0.2,
|
||||
ChorusError::Base64Decode(_) => 0.0,
|
||||
ChorusError::BlockedIp => 0.0,
|
||||
ChorusError::BlossomAuthFailure(_) => 0.0,
|
||||
ChorusError::ChannelRecv(_) => 0.0,
|
||||
ChorusError::ChannelSend(_) => 0.0,
|
||||
ChorusError::Config(_) => 0.0,
|
||||
@ -288,6 +304,7 @@ impl ChorusError {
|
||||
ChorusError::Io(_) => 0.0,
|
||||
ChorusError::ManagementAuthFailure(_) => 0.0,
|
||||
ChorusError::MissingTable(_) => 0.0,
|
||||
ChorusError::NonAsciiHttpHeaderValue(_) => 0.2,
|
||||
ChorusError::NoPrivateKey => 0.0,
|
||||
ChorusError::NotImplemented => 0.0,
|
||||
ChorusError::NoSuchSubscription => 0.05,
|
||||
@ -301,6 +318,7 @@ impl ChorusError {
|
||||
ChorusError::Rustls(_) => 0.0,
|
||||
ChorusError::Scraper => 0.4,
|
||||
ChorusError::SerdeJson(_) => 0.0,
|
||||
ChorusError::SignalNotBlossom => 0.0,
|
||||
ChorusError::Speedy(_) => 0.0,
|
||||
ChorusError::TimedOut => 0.1,
|
||||
ChorusError::TooManySubscriptions => 0.1,
|
||||
@ -420,6 +438,16 @@ impl From<std::io::Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<http::header::ToStrError> for Error {
|
||||
#[track_caller]
|
||||
fn from(err: http::header::ToStrError) -> Self {
|
||||
Error {
|
||||
inner: ChorusError::NonAsciiHttpHeaderValue(err),
|
||||
location: std::panic::Location::caller(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<pocket_db::Error> for Error {
|
||||
#[track_caller]
|
||||
fn from(err: pocket_db::Error) -> Self {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user