feat(api): series, season and episode endpoints (#81)
This commit was merged in pull request #81.
This commit is contained in:
@@ -85,6 +85,9 @@ pub struct ErrorBody {
|
||||
#[derive(Debug)]
|
||||
pub enum ApiError {
|
||||
NotFound,
|
||||
SeriesNotFound,
|
||||
SeasonNotFound,
|
||||
EpisodeNotFound,
|
||||
OwnerNotFound,
|
||||
Conflict(String),
|
||||
Invalid(String),
|
||||
@@ -96,6 +99,9 @@ impl IntoResponse for ApiError {
|
||||
fn into_response(self) -> Response {
|
||||
let (status, error) = match self {
|
||||
Self::NotFound => (StatusCode::NOT_FOUND, "movie not found".to_string()),
|
||||
Self::SeriesNotFound => (StatusCode::NOT_FOUND, "series not found".to_string()),
|
||||
Self::SeasonNotFound => (StatusCode::NOT_FOUND, "season not found".to_string()),
|
||||
Self::EpisodeNotFound => (StatusCode::NOT_FOUND, "episode not found".to_string()),
|
||||
Self::OwnerNotFound => (StatusCode::NOT_FOUND, "owner not found".to_string()),
|
||||
Self::Conflict(error) => (StatusCode::CONFLICT, error),
|
||||
Self::Invalid(error) => (StatusCode::UNPROCESSABLE_ENTITY, error),
|
||||
@@ -104,7 +110,7 @@ impl IntoResponse for ApiError {
|
||||
"database unavailable".into(),
|
||||
),
|
||||
Self::Database(error) => {
|
||||
tracing::error!(%error, "movie API database error");
|
||||
tracing::error!(%error, "API database error");
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, "database error".into())
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user