Debian Codegraph @

podcasts-data/src/errors.rs

raw symbols SCIP
1 // errors.rs
2 //
3 // Copyright 2017 Jordan Petridis <[email protected]>
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // SPDX-License-Identifier: GPL-3.0-or-later
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 }