2020-04-01 21:35:24 +02:00
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum TimelineErr {
|
2020-04-11 04:36:03 +02:00
|
|
|
MissingHashtag,
|
2020-04-01 21:35:24 +02:00
|
|
|
InvalidInput,
|
2020-04-13 21:40:36 +02:00
|
|
|
BadTag,
|
2020-04-01 21:35:24 +02:00
|
|
|
}
|
|
|
|
|
2020-04-11 04:36:03 +02:00
|
|
|
impl std::error::Error for TimelineErr {}
|
|
|
|
|
2020-04-01 21:35:24 +02:00
|
|
|
impl From<std::num::ParseIntError> for TimelineErr {
|
|
|
|
fn from(_error: std::num::ParseIntError) -> Self {
|
|
|
|
Self::InvalidInput
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for TimelineErr {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
|
|
|
|
use TimelineErr::*;
|
|
|
|
let msg = match self {
|
2020-04-11 04:36:03 +02:00
|
|
|
InvalidInput => "The timeline text from Redis could not be parsed into a supported timeline. TODO: add incoming timeline text",
|
|
|
|
MissingHashtag => "Attempted to send a hashtag timeline without supplying a tag name",
|
2020-04-13 21:40:36 +02:00
|
|
|
BadTag => "No hashtag exists with the specified hashtag ID"
|
2020-04-01 21:35:24 +02:00
|
|
|
};
|
|
|
|
write!(f, "{}", msg)
|
|
|
|
}
|
|
|
|
}
|