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

com.twitter.finatra.json.internal.caseclass.jackson.JacksonUtils.scala Maven / Gradle / Ivy

There is a newer version: 2.1.6
Show newest version
package com.twitter.finatra.json.internal.caseclass.jackson

import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.JsonMappingException
import com.twitter.finatra.json.internal.caseclass.exceptions.FinatraJsonMappingException

object JacksonUtils {

  /* Public */
  def errorMessage(e: JsonProcessingException): String = e match {
    case fjme: FinatraJsonMappingException =>
      fjme.getMessage // One of our deserializers/validations failed and we want to pass this message on to the user
    case jme: JsonMappingException =>
      "Unable to parse" // Prevent JsonMappingException from leaking implementation details
    case _ if e.getCause == null =>
      e.getOriginalMessage // jackson threw the original error
    case _ =>
      e.getCause.getMessage // custom deserialization code threw the exception (e.g., enum deserialization)
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy