com.gu.contentapi.client.model.ContentApiError.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of content-api-client_2.12 Show documentation
Show all versions of content-api-client_2.12 Show documentation
Scala client for the Guardian's Content API
The newest version!
package com.gu.contentapi.client.model
import com.gu.contentapi.client.model.v1.ErrorResponse
import com.gu.contentapi.client.thrift.ThriftDeserializer
import scala.util.Try
case class ContentApiError(httpStatus: Int, httpMessage: String, errorResponse: Option[ErrorResponse] = None) extends RuntimeException(httpMessage)
object ContentApiError {
def apply(response: HttpResponse): ContentApiError = {
val errorResponse = Try(ThriftDeserializer.deserialize(response.body, ErrorResponse)).toOption
ContentApiError(response.statusCode, response.statusMessage, errorResponse)
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy