| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
use diesel::r2d2; |
| 21 |
|
| 22 |
use std::io; |
| 23 |
|
| 24 |
use crate::models::{ShowId, Source}; |
| 25 |
use thiserror::Error; |
| 26 |
|
| 27 |
#[derive(Error, Debug)] |
| 28 |
pub enum DataError { |
| 29 |
#[error("SQL Query failed: {0}")] |
| 30 |
DieselResultError(#[from] diesel::result::Error), |
| 31 |
#[error("Database Migration error")] |
| 32 |
DieselMigrationError, |
| 33 |
#[error("R2D2 error: {0}")] |
| 34 |
R2D2Error(#[from] r2d2::Error), |
| 35 |
#[error("R2D2 Pool error: {0}")] |
| 36 |
R2D2PoolError(#[from] r2d2::PoolError), |
| 37 |
#[error("ToStr Error: {0}")] |
| 38 |
HttpToStr(#[from] http::header::ToStrError), |
| 39 |
#[error("Failed to parse a url: {0}")] |
| 40 |
UrlError(#[from] url::ParseError), |
| 41 |
#[error("TLS Error: {0}")] |
| 42 |
ReqwestError(#[from] reqwest::Error), |
| 43 |
#[error("IO Error: {0}")] |
| 44 |
IOError(#[from] io::Error), |
| 45 |
#[error("RSS Error: {0}")] |
| 46 |
RssError(#[from] rss::Error), |
| 47 |
#[error("XML Reader Error: {0}")] |
| 48 |
XmlReaderError(#[from] xml::reader::Error), |
| 49 |
#[error("Error: {0}")] |
| 50 |
Bail(String), |
| 51 |
#[error("Request to {url} returned {status_code}. Context: {context}")] |
| 52 |
HttpStatusGeneral { |
| 53 |
url: String, |
| 54 |
status_code: reqwest::StatusCode, |
| 55 |
context: String, |
| 56 |
}, |
| 57 |
#[error("Source redirects to a new url")] |
| 58 |
FeedRedirect(Source), |
| 59 |
#[error("Feed is up to date")] |
| 60 |
FeedNotModified(Source), |
| 61 |
#[error("Error occurred while Parsing an Episode. Reason: {}", reason)] |
| 62 |
ParseEpisodeError { reason: String, parent_id: ShowId }, |
| 63 |
#[error("Episode was not changed and thus skipped.")] |
| 64 |
EpisodeNotChanged, |
| 65 |
#[error("Invalid Uri Error: {0}")] |
| 66 |
InvalidUri(#[from] http::uri::InvalidUri), |
| 67 |
#[error("Builder error: {0}")] |
| 68 |
BuilderError(String), |
| 69 |
} |
| 70 |
|
| 71 |
#[derive(Error, Debug)] |
| 72 |
pub enum DownloadError { |
| 73 |
#[error("Request error: {0}")] |
| 74 |
RequestError(#[from] reqwest::Error), |
| 75 |
#[error("Data error: {0}")] |
| 76 |
DataError(#[from] DataError), |
| 77 |
#[error("Io error: {0}")] |
| 78 |
IoError(#[from] io::Error), |
| 79 |
#[error("Unexpected server response: {0}")] |
| 80 |
UnexpectedResponse(reqwest::StatusCode), |
| 81 |
#[error("The Download was cancelled.")] |
| 82 |
DownloadCancelled, |
| 83 |
#[error("Remote Image location not found.")] |
| 84 |
NoImageLocation, |
| 85 |
#[error("Failed to parse CacheLocation.")] |
| 86 |
InvalidCacheLocation, |
| 87 |
#[error("Failed to parse Cached Image Location.")] |
| 88 |
InvalidCachedImageLocation, |
| 89 |
#[error("Download no longer needed.")] |
| 90 |
NoLongerNeeded, |
| 91 |
} |