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

com.codahale.jerkson.ParsingException.scala Maven / Gradle / Ivy

There is a newer version: 0.6.3
Show newest version
package com.codahale.jerkson

import java.io.IOException
import com.fasterxml.jackson.databind.JsonMappingException
import com.fasterxml.jackson.core.{JsonParseException, JsonProcessingException}

object ParsingException {
  def apply(cause: JsonProcessingException): ParsingException = {
    val message = cause match {
      case e: JsonMappingException => e.getMessage
      case e: JsonParseException => {
        val fake = new JsonParseException("", e.getLocation)
        val msg = e.getMessage.replace(fake.getMessage, "").replaceAll(""" (\(from.*\))""", "")
        "Malformed JSON. %s at character offset %d.".format(msg, e.getLocation.getCharOffset)
      }
    }
    new ParsingException(message, cause)
  }
}

class ParsingException(message: String, cause: Throwable)
        extends IOException(message, cause)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy