bilibili_extractor_lib/
error.rs

1pub type Result<T> = std::result::Result<T, Error>;
2
3#[derive(Debug, thiserror::Error)]
4pub enum Error {
5    #[error("IO Error: {0}")]
6    IOError(#[from] std::io::Error),
7
8    #[error("Serde JSON error: {0}")]
9    SerdeJSONError(#[from] serde_json::Error),
10
11    #[error("Parse Integer error: {0}")]
12    ParseIntError(#[from] std::num::ParseIntError),
13
14    #[error("Bilibili Extractor error: {0}")]
15    BilibiliExtractorError(String),
16}
17
18impl From<&str> for Error {
19    fn from(s: &str) -> Self {
20        Error::BilibiliExtractorError(s.to_string())
21    }
22}
23
24impl From<String> for Error {
25    fn from(s: String) -> Self {
26        Error::BilibiliExtractorError(s)
27    }
28}