torrust_tracker/servers/http/v1/handlers/common/
auth.rs1use std::panic::Location;
5
6use thiserror::Error;
7
8use crate::core::auth;
9use crate::servers::http::v1::responses;
10
11#[derive(Debug, Error)]
17pub enum Error {
18 #[error("Missing authentication key param for private tracker. Error in {location}")]
19 MissingAuthKey { location: &'static Location<'static> },
20 #[error("Invalid format for authentication key param. Error in {location}")]
21 InvalidKeyFormat { location: &'static Location<'static> },
22 #[error("Cannot extract authentication key param from URL path. Error in {location}")]
23 CannotExtractKeyParam { location: &'static Location<'static> },
24}
25
26impl From<Error> for responses::error::Error {
27 fn from(err: Error) -> Self {
28 responses::error::Error {
29 failure_reason: format!("Authentication error: {err}"),
30 }
31 }
32}
33
34impl From<auth::Error> for responses::error::Error {
35 fn from(err: auth::Error) -> Self {
36 responses::error::Error {
37 failure_reason: format!("Authentication error: {err}"),
38 }
39 }
40}