All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mesosphere.cosmos.error.RepositoryNotPresent.scala Maven / Gradle / Ivy

There is a newer version: 0.4.4
Show newest version
package com.mesosphere.cosmos.error

import cats.data.Ior
import com.mesosphere.universe.common.circe.Encoders._
import com.netaporter.uri.Uri
import io.circe.Encoder
import io.circe.JsonObject
import io.circe.generic.semiauto.deriveEncoder
import io.circe.syntax._

final case class RepositoryNotPresent(nameOrUri: Ior[String, Uri]) extends CosmosError {
  override def data: Option[JsonObject] = {
    val jsonMap = nameOrUri match {
      case Ior.Both(n, u) => Map("name" -> n.asJson, "uri" -> u.asJson)
      case Ior.Left(n) => Map("name" -> n.asJson)
      case Ior.Right(u) => Map("uri" -> u.asJson)
    }
    Some(JsonObject.fromMap(jsonMap))
  }
  override def message: String = {
    nameOrUri match {
      case Ior.Both(n, u) => s"Neither repository name [$n] nor URI [$u] are present in the list"
      case Ior.Left(n) => s"Repository name [$n] is not present in the list"
      case Ior.Right(u) => s"Repository URI [$u] is not present in the list"
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy