torrust_tracker/core/
error.rs1use std::panic::Location;
10
11use torrust_tracker_located_error::LocatedError;
12use torrust_tracker_primitives::info_hash::InfoHash;
13
14use super::auth::ParseKeyError;
15use super::databases;
16
17#[derive(thiserror::Error, Debug, Clone)]
19pub enum Error {
20 #[error("The supplied key: {key:?}, is not valid: {source}")]
22 PeerKeyNotValid {
23 key: super::auth::Key,
24 source: LocatedError<'static, dyn std::error::Error + Send + Sync>,
25 },
26
27 #[error("The peer is not authenticated, {location}")]
28 PeerNotAuthenticated { location: &'static Location<'static> },
29
30 #[error("The torrent: {info_hash}, is not whitelisted, {location}")]
32 TorrentNotWhitelisted {
33 info_hash: InfoHash,
34 location: &'static Location<'static>,
35 },
36}
37
38#[allow(clippy::module_name_repetitions)]
40#[derive(thiserror::Error, Debug, Clone)]
41pub enum PeerKeyError {
42 #[error("Invalid peer key duration: {seconds_valid:?}, is not valid")]
43 DurationOverflow { seconds_valid: u64 },
44
45 #[error("Invalid key: {key}")]
46 InvalidKey {
47 key: String,
48 source: LocatedError<'static, ParseKeyError>,
49 },
50
51 #[error("Can't persist key: {source}")]
52 DatabaseError {
53 source: LocatedError<'static, databases::error::Error>,
54 },
55}