sitemap_rs/
video_error.rs1use std::error;
2use std::fmt::{Display, Formatter};
3
4#[derive(Debug)]
6pub enum VideoError {
7 DescriptionTooLong(usize),
9
10 DurationTooShort(u16),
12
13 DurationTooLong(u16),
15
16 RatingTooLow(f32),
18
19 RatingTooHigh(f32),
21
22 UploaderNameTooLong(usize),
24
25 TooManyTags(usize),
27}
28
29impl error::Error for VideoError {}
30
31impl Display for VideoError {
32 fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
33 match self {
34 Self::DescriptionTooLong(count) => {
35 write!(
36 f,
37 "description cannot be longer than 2048 characters: {count}"
38 )
39 }
40 Self::DurationTooShort(duration) => {
41 write!(f, "duration is below 1 (second): {duration}")
42 }
43 Self::DurationTooLong(duration) => {
44 write!(f, "duration is above 28,800 (seconds): {duration}")
45 }
46 Self::RatingTooLow(rating) => {
47 write!(f, "rating is below 0.0: {rating}")
48 }
49 Self::RatingTooHigh(rating) => {
50 write!(f, "rating is above 5.0: {rating}")
51 }
52 Self::UploaderNameTooLong(count) => {
53 write!(f, "uploader name is longer than 255 characters: {count}")
54 }
55 Self::TooManyTags(count) => {
56 write!(f, "must not have more than 32 tags: {count}")
57 }
58 }
59 }
60}