def current()

in membership-common/src/main/scala/com/gu/memsub/subsv2/services/SubscriptionService.scala [92:107]


  def current(contact: ContactId)(implicit logPrefix: LogPrefix): M[List[Subscription]] =
    for {
      subscriptionsEither <- getSubscriptionsFromContact(contact)
      catalog <- futureCatalog(logPrefix)
    } yield {
      val currentSubscriptions = for {
        subscriptions <- subscriptionsEither.withLogging("sub service - get for contact")
        currentSubscriptions <- getCurrentSubscriptions(catalog, subscriptions).withLogging("get best plan")
      } yield currentSubscriptions
      currentSubscriptions.toEither match {
        case Left(error) =>
          logger.warn(s"Error from sub service for contact $contact: $error")
          List.empty // returns an empty list if there's an error
        case Right(nel) => nel.toList
      }
    }