1use std::fmt;
2
3#[derive(Debug, PartialEq)]
6pub enum GetPriceError {
7 PriceTooOld,
8 MismatchedFeedId,
9 InsufficientVerificationLevel,
10 FeedIdMustBe32Bytes,
11 FeedIdNonHexCharacter,
12}
13
14impl fmt::Display for GetPriceError {
15 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16 match self {
17 GetPriceError::PriceTooOld => write!(f, "This price feed update's age exceeds the requested maximum age"),
18 GetPriceError::MismatchedFeedId => write!(f, "The price feed update doesn't match the requested feed id"),
19 GetPriceError::InsufficientVerificationLevel => write!(f, "This price feed update has a lower verification level than the one requested"),
20 GetPriceError::FeedIdMustBe32Bytes => write!(f, "Feed id must be 32 Bytes, that's 64 hex characters or 66 with a 0x prefix"),
21 GetPriceError::FeedIdNonHexCharacter => write!(f, "Feed id contains non-hex characters"),
22 }
23 }
24}
25
26impl std::error::Error for GetPriceError {}
27
28pub type Result<T> = std::result::Result<T, GetPriceError>;