use std::error::Error;
use std::fmt::{Display, Formatter};
#[derive(Debug)]
pub enum BrokerError {
NetworkError(String),
BrokerError(String),
}
impl Error for BrokerError {}
impl Display for BrokerError {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
BrokerError::NetworkError(e) => {write!(f, "NETWORK_ERROR: {}", e)}
BrokerError::BrokerError(e) => {write!(f, "BROKER_ERROR: {}", e)}
}
}
}
impl From<reqwest::Error> for BrokerError {
fn from(e: reqwest::Error) -> Self {
BrokerError::NetworkError(e.to_string())
}
}
#[cfg(test)]
mod tests {
use crate::{BgpkitBroker, CollectorLatestItem};
#[test]
fn test_anyhow() {
fn test_error() -> anyhow::Result<Vec<CollectorLatestItem>> {
Ok(BgpkitBroker::new().latest()?)
}
let _res = test_error();
}
}