@@ -148,7 +148,7 @@ pub enum ServiceError {
148
148
#[ display( fmt = "Database error." ) ]
149
149
DatabaseError ,
150
150
151
- // Tracker errors
151
+ // Begin tracker errors
152
152
#[ display( fmt = "Sorry, we have an error with our tracker connection." ) ]
153
153
TrackerOffline ,
154
154
@@ -160,6 +160,10 @@ pub enum ServiceError {
160
160
161
161
#[ display( fmt = "Torrent not found in tracker." ) ]
162
162
TorrentNotFoundInTracker ,
163
+
164
+ #[ display( fmt = "Invalid tracker API token." ) ]
165
+ InvalidTrackerToken ,
166
+ // End tracker errors
163
167
}
164
168
165
169
impl From < sqlx:: Error > for ServiceError {
@@ -244,14 +248,13 @@ impl From<TrackerAPIError> for ServiceError {
244
248
eprintln ! ( "{e}" ) ;
245
249
match e {
246
250
TrackerAPIError :: TrackerOffline => ServiceError :: TrackerOffline ,
247
- TrackerAPIError :: AddToWhitelistError
248
- | TrackerAPIError :: RemoveFromWhitelistError
249
- | TrackerAPIError :: RetrieveUserKeyError => ServiceError :: TrackerResponseError ,
251
+ TrackerAPIError :: InternalServerError => ServiceError :: TrackerResponseError ,
250
252
TrackerAPIError :: TorrentNotFound => ServiceError :: TorrentNotFoundInTracker ,
251
- TrackerAPIError :: MissingResponseBody | TrackerAPIError :: FailedToParseTrackerResponse { body : _ } => {
252
- ServiceError :: TrackerUnknownResponse
253
- }
253
+ TrackerAPIError :: UnexpectedResponseStatus
254
+ | TrackerAPIError :: MissingResponseBody
255
+ | TrackerAPIError :: FailedToParseTrackerResponse { body : _ } => ServiceError :: TrackerUnknownResponse ,
254
256
TrackerAPIError :: CannotSaveUserKey => ServiceError :: DatabaseError ,
257
+ TrackerAPIError :: InvalidToken => ServiceError :: InvalidTrackerToken ,
255
258
}
256
259
}
257
260
}
@@ -307,6 +310,7 @@ pub fn http_status_code_for_service_error(error: &ServiceError) -> StatusCode {
307
310
ServiceError :: TrackerResponseError => StatusCode :: INTERNAL_SERVER_ERROR ,
308
311
ServiceError :: TrackerUnknownResponse => StatusCode :: INTERNAL_SERVER_ERROR ,
309
312
ServiceError :: TorrentNotFoundInTracker => StatusCode :: NOT_FOUND ,
313
+ ServiceError :: InvalidTrackerToken => StatusCode :: INTERNAL_SERVER_ERROR ,
310
314
}
311
315
}
312
316
0 commit comments