com.fasterxml.jackson.databind
Class JsonMappingException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by com.fasterxml.jackson.core.JsonProcessingException
                  extended by com.fasterxml.jackson.databind.JsonMappingException
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
UnrecognizedPropertyException

public class JsonMappingException
extends com.fasterxml.jackson.core.JsonProcessingException

Checked exception used to signal fatal problems with mapping of content.

One additional feature is the ability to denote relevant path of references (during serialization/deserialization) to help in troubleshooting.

See Also:
Serialized Form

Nested Class Summary
static class JsonMappingException.Reference
          Simple bean class used to contain references.
 
Field Summary
protected  LinkedList<JsonMappingException.Reference> _path
          Path through which problem that triggering throwing of this exception was reached.
 
Fields inherited from class com.fasterxml.jackson.core.JsonProcessingException
_location
 
Constructor Summary
JsonMappingException(String msg)
           
JsonMappingException(String msg, com.fasterxml.jackson.core.JsonLocation loc)
           
JsonMappingException(String msg, com.fasterxml.jackson.core.JsonLocation loc, Throwable rootCause)
           
JsonMappingException(String msg, Throwable rootCause)
           
 
Method Summary
protected  void _appendPathDesc(StringBuilder sb)
           
protected  String _buildMessage()
           
static JsonMappingException from(com.fasterxml.jackson.core.JsonParser jp, String msg)
           
static JsonMappingException from(com.fasterxml.jackson.core.JsonParser jp, String msg, Throwable problem)
           
 String getLocalizedMessage()
           
 String getMessage()
          Method is overridden so that we can properly inject description of problem path, if such is defined.
 List<JsonMappingException.Reference> getPath()
          Method for accessing full structural path within type hierarchy down to problematic property.
 String getPathReference()
          Method for accesing description of path that lead to the problem that triggered this exception
 StringBuilder getPathReference(StringBuilder sb)
           
 void prependPath(JsonMappingException.Reference r)
           
 void prependPath(Object referrer, int index)
          Method called to prepend a reference information in front of current path
 void prependPath(Object referrer, String fieldName)
          Method called to prepend a reference information in front of current path
 String toString()
           
static JsonMappingException wrapWithPath(Throwable src, JsonMappingException.Reference ref)
          Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.
static JsonMappingException wrapWithPath(Throwable src, Object refFrom, int index)
          Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.
static JsonMappingException wrapWithPath(Throwable src, Object refFrom, String refFieldName)
          Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.
 
Methods inherited from class com.fasterxml.jackson.core.JsonProcessingException
getLocation, getMessageSuffix
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_path

protected LinkedList<JsonMappingException.Reference> _path
Path through which problem that triggering throwing of this exception was reached.

Constructor Detail

JsonMappingException

public JsonMappingException(String msg)

JsonMappingException

public JsonMappingException(String msg,
                            Throwable rootCause)

JsonMappingException

public JsonMappingException(String msg,
                            com.fasterxml.jackson.core.JsonLocation loc)

JsonMappingException

public JsonMappingException(String msg,
                            com.fasterxml.jackson.core.JsonLocation loc,
                            Throwable rootCause)
Method Detail

from

public static JsonMappingException from(com.fasterxml.jackson.core.JsonParser jp,
                                        String msg)

from

public static JsonMappingException from(com.fasterxml.jackson.core.JsonParser jp,
                                        String msg,
                                        Throwable problem)

wrapWithPath

public static JsonMappingException wrapWithPath(Throwable src,
                                                Object refFrom,
                                                String refFieldName)
Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information. This version of method is called when the reference is through a non-indexed object, such as a Map or POJO/bean.


wrapWithPath

public static JsonMappingException wrapWithPath(Throwable src,
                                                Object refFrom,
                                                int index)
Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information. This version of method is called when the reference is through an index, which happens with arrays and Collections.


wrapWithPath

public static JsonMappingException wrapWithPath(Throwable src,
                                                JsonMappingException.Reference ref)
Method that can be called to either create a new JsonMappingException (if underlying exception is not a JsonMappingException), or augment given exception with given path/reference information.


getPath

public List<JsonMappingException.Reference> getPath()
Method for accessing full structural path within type hierarchy down to problematic property.


getPathReference

public String getPathReference()
Method for accesing description of path that lead to the problem that triggered this exception


getPathReference

public StringBuilder getPathReference(StringBuilder sb)

prependPath

public void prependPath(Object referrer,
                        String fieldName)
Method called to prepend a reference information in front of current path


prependPath

public void prependPath(Object referrer,
                        int index)
Method called to prepend a reference information in front of current path


prependPath

public void prependPath(JsonMappingException.Reference r)

getLocalizedMessage

public String getLocalizedMessage()
Overrides:
getLocalizedMessage in class Throwable

getMessage

public String getMessage()
Method is overridden so that we can properly inject description of problem path, if such is defined.

Overrides:
getMessage in class com.fasterxml.jackson.core.JsonProcessingException

_buildMessage

protected String _buildMessage()

toString

public String toString()
Overrides:
toString in class com.fasterxml.jackson.core.JsonProcessingException

_appendPathDesc

protected void _appendPathDesc(StringBuilder sb)


Copyright © 2012 fasterxml.com. All Rights Reserved.