Skip to content

Commit 07c6e89

Browse files
committed
refactor: rename UDP tracker server error variants
1 parent 21bea5b commit 07c6e89

File tree

3 files changed

+14
-14
lines changed

3 files changed

+14
-14
lines changed

packages/udp-tracker-server/src/error.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,47 +17,47 @@ pub struct ConnectionCookie(pub ConnectionId);
1717
pub enum Error {
1818
/// Error returned when the request is invalid.
1919
#[error("error parsing request: {request_parse_error:?}")]
20-
RequestParseError { request_parse_error: SendableRequestParseError },
20+
InvalidRequest { request_parse_error: SendableRequestParseError },
2121

2222
/// Error returned when the domain tracker returns an announce error.
2323
#[error("tracker announce error: {source}")]
24-
UdpAnnounceError { source: UdpAnnounceError },
24+
AnnounceFailed { source: UdpAnnounceError },
2525

2626
/// Error returned when the domain tracker returns an scrape error.
2727
#[error("tracker scrape error: {source}")]
28-
UdpScrapeError { source: UdpScrapeError },
28+
ScrapeFailed { source: UdpScrapeError },
2929

3030
/// Error returned from a third-party library (`aquatic_udp_protocol`).
3131
#[error("internal server error: {message}, {location}")]
32-
InternalServer {
32+
Internal {
3333
location: &'static Location<'static>,
3434
message: String,
3535
},
3636

3737
/// Error returned when tracker requires authentication.
3838
#[error("domain tracker requires authentication but is not supported in current UDP implementation. Location: {location}")]
39-
TrackerAuthenticationRequired { location: &'static Location<'static> },
39+
AuthRequired { location: &'static Location<'static> },
4040
}
4141

4242
impl From<RequestParseError> for Error {
4343
fn from(request_parse_error: RequestParseError) -> Self {
44-
Self::RequestParseError {
44+
Self::InvalidRequest {
4545
request_parse_error: request_parse_error.into(),
4646
}
4747
}
4848
}
4949

5050
impl From<UdpAnnounceError> for Error {
5151
fn from(udp_announce_error: UdpAnnounceError) -> Self {
52-
Self::UdpAnnounceError {
52+
Self::AnnounceFailed {
5353
source: udp_announce_error,
5454
}
5555
}
5656
}
5757

5858
impl From<UdpScrapeError> for Error {
5959
fn from(udp_scrape_error: UdpScrapeError) -> Self {
60-
Self::UdpScrapeError {
60+
Self::ScrapeFailed {
6161
source: udp_scrape_error,
6262
}
6363
}

packages/udp-tracker-server/src/event.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,24 +129,24 @@ pub enum ErrorKind {
129129
impl From<Error> for ErrorKind {
130130
fn from(error: Error) -> Self {
131131
match error {
132-
Error::RequestParseError { request_parse_error } => Self::RequestParse(request_parse_error.to_string()),
133-
Error::UdpAnnounceError { source } => match source {
132+
Error::InvalidRequest { request_parse_error } => Self::RequestParse(request_parse_error.to_string()),
133+
Error::AnnounceFailed { source } => match source {
134134
UdpAnnounceError::ConnectionCookieError { source } => Self::ConnectionCookie(source.to_string()),
135135
UdpAnnounceError::TrackerCoreAnnounceError { source } => match source {
136136
AnnounceError::Whitelist(whitelist_error) => Self::Whitelist(whitelist_error.to_string()),
137137
AnnounceError::Database(error) => Self::Database(error.to_string()),
138138
},
139139
UdpAnnounceError::TrackerCoreWhitelistError { source } => Self::Whitelist(source.to_string()),
140140
},
141-
Error::UdpScrapeError { source } => match source {
141+
Error::ScrapeFailed { source } => match source {
142142
UdpScrapeError::ConnectionCookieError { source } => Self::ConnectionCookie(source.to_string()),
143143
UdpScrapeError::TrackerCoreScrapeError { source } => match source {
144144
ScrapeError::Whitelist(whitelist_error) => Self::Whitelist(whitelist_error.to_string()),
145145
},
146146
UdpScrapeError::TrackerCoreWhitelistError { source } => Self::Whitelist(source.to_string()),
147147
},
148-
Error::InternalServer { location: _, message } => Self::InternalServer(message.to_string()),
149-
Error::TrackerAuthenticationRequired { location } => Self::TrackerAuthentication(location.to_string()),
148+
Error::Internal { location: _, message } => Self::InternalServer(message.to_string()),
149+
Error::AuthRequired { location } => Self::TrackerAuthentication(location.to_string()),
150150
}
151151
}
152152
}

packages/udp-tracker-server/src/handlers/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ pub(crate) async fn handle_packet(
101101
Err(e) => {
102102
// The request payload could not be parsed, so we handle it as an error.
103103

104-
let opt_transaction_id = if let Error::RequestParseError { request_parse_error } = e.clone() {
104+
let opt_transaction_id = if let Error::InvalidRequest { request_parse_error } = e.clone() {
105105
request_parse_error.opt_transaction_id
106106
} else {
107107
None

0 commit comments

Comments
 (0)