diff --git a/src/error.rs b/src/error.rs index 9de1953..8fca380 100644 --- a/src/error.rs +++ b/src/error.rs @@ -94,6 +94,9 @@ pub enum ChorusError { // Filter is underspecified Scraper, + // URL Parse + UrlParse(url::ParseError), + // UTF-8 Utf8(std::str::Utf8Error), @@ -143,6 +146,7 @@ impl std::fmt::Display for ChorusError { ChorusError::Rustls(e) => write!(f, "{e}"), ChorusError::Tungstenite(e) => write!(f, "{e}"), ChorusError::Scraper => write!(f, "Filter is underspecified. Scrapers are not allowed"), + ChorusError::UrlParse(e) => write!(f, "{e}"), ChorusError::Utf8(e) => write!(f, "{e}"), ChorusError::Utf8Error => write!(f, "UTF-8 error"), ChorusError::WebsocketProtocol(e) => write!(f, "{e}"), @@ -163,6 +167,7 @@ impl StdError for ChorusError { ChorusError::Lmdb(e) => Some(e), ChorusError::Rustls(e) => Some(e), ChorusError::Tungstenite(e) => Some(e), + ChorusError::UrlParse(e) => Some(e), ChorusError::Utf8(e) => Some(e), ChorusError::WebsocketProtocol(e) => Some(e), _ => None, @@ -306,3 +311,13 @@ impl From for Error { } } } + +impl From for Error { + #[track_caller] + fn from(err: url::ParseError) -> Self { + Error { + inner: ChorusError::UrlParse(err), + location: std::panic::Location::caller(), + } + } +}