Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress 500 errors during RSS fetching #166

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/scala/plex/PlexUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import org.slf4j.LoggerFactory
import io.circe.generic.extras
import io.circe.generic.extras.auto._
import io.circe.syntax.EncoderOps
import org.http4s.client.UnexpectedStatus

trait PlexUtils {

Expand All @@ -23,13 +24,16 @@ trait PlexUtils {
val jsonFormatUrl = url.withQueryParam("format", "json")

client.httpRequest(Method.GET, jsonFormatUrl).map {
case Left(UnexpectedStatus(s, _, _)) if s.code == 500 =>
logger.debug(s"Unable to fetch watchlist from Plex, see https://github.com/nylonee/watchlistarr/issues/161")
Set.empty
case Left(err) =>
logger.warn(s"Unable to fetch watchlist from Plex: $err")
Set.empty
case Right(json) =>
logger.debug("Found Json from Plex watchlist, attempting to decode")
json.as[Watchlist].map(_.items).getOrElse {
logger.warn("Unable to fetch watchlist from Plex - decoding failure. Returning empty list instead")
logger.warn("Unable to fetch watchlist from Plex - decoding failure")
Set.empty
}
}
Expand Down
Loading