fix(api): search survives a down TMDB and errors name the upstream
This commit is contained in:
@@ -159,7 +159,12 @@ pub enum ApiError {
|
||||
NoTrailer,
|
||||
Conflict(String),
|
||||
Invalid(String),
|
||||
/// The SQLite handle is gone. Distinct from [`Self::Upstream`] so a
|
||||
/// TMDB or Prowlarr fault never reads as a database fault (issue #168).
|
||||
Unavailable,
|
||||
/// An upstream service could not be reached, is misconfigured or is
|
||||
/// unconfigured. The payload names it.
|
||||
Upstream(&'static str),
|
||||
Database(String),
|
||||
/// A library delete that could not touch the disk. Named separately from
|
||||
/// [`Self::Database`] because the row is still there and a retry is the
|
||||
@@ -184,6 +189,10 @@ impl IntoResponse for ApiError {
|
||||
StatusCode::SERVICE_UNAVAILABLE,
|
||||
"database unavailable".into(),
|
||||
),
|
||||
Self::Upstream(name) => (
|
||||
StatusCode::SERVICE_UNAVAILABLE,
|
||||
format!("{name} unavailable"),
|
||||
),
|
||||
Self::Database(error) => {
|
||||
tracing::error!(%error, "API database error");
|
||||
(StatusCode::INTERNAL_SERVER_ERROR, "database error".into())
|
||||
@@ -554,7 +563,7 @@ pub async fn search(
|
||||
}
|
||||
state
|
||||
.send_movie_command(MovieCommand::Search { movie_id: id })
|
||||
.map_err(|_| ApiError::Unavailable)?;
|
||||
.map_err(|_| ApiError::Upstream("daemon"))?;
|
||||
Ok((StatusCode::ACCEPTED, Json(Accepted { accepted: true })))
|
||||
}
|
||||
|
||||
@@ -671,7 +680,7 @@ pub async fn grab(
|
||||
movie_id,
|
||||
release_id,
|
||||
})
|
||||
.map_err(|_| ApiError::Unavailable)?;
|
||||
.map_err(|_| ApiError::Upstream("daemon"))?;
|
||||
Ok((StatusCode::ACCEPTED, Json(Accepted { accepted: true })))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user