def upsertContentResponse()

in common-lib/src/main/scala/com/gu/workflow/lib/DBResponseToAPI.scala [12:31]


  def upsertContentResponse(cuEit: Either[ContentUpdateError, ContentUpdate]): ApiResponseFt[ContentUpdate] = {
    cuEit match {
      case Left(db: DatabaseError) =>
        logger.error(s"ContentUpdateError - DatabaseError - ${db.message}")
        ApiResponseFt.Left(ApiError.databaseError(db.message))
      case Left(ContentItemExists) =>
        logger.error("ContentUpdateError - ContentItemExists")
        ApiResponseFt.Left(ApiError.conflict)
      case Left(s: StubNotFound) =>
        logger.error(s"ContentUpdateError - StubNotFound - ${s.id}")
        ApiResponseFt.Left(ApiError.updateError(s.id))
      case Left(s: UpdateRevisionTooLow) =>
        logger.error(s"ContentUpdateError - UpdateRevisionTooLow stubid: ${s.stubId} updateRevision: ${s.updateRevision}")
        ApiResponseFt.Left(ApiError.updateErrorRevisionTooLow(s))
      case Left(c: ComposerIdsConflict) =>
        logger.error("ContentUpdateError - ComposerIdsConflict")
        ApiResponseFt.Left(ApiError.conflict)
      case Right(cu) => ApiResponseFt.Right(cu)
    }
  }