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

com.gu.contentapi.client.model.ContentApiError.scala Maven / Gradle / Ivy

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