Package org.codehaus.jackson.map
Class JsonMappingException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.io.IOException
-
- org.codehaus.jackson.JsonProcessingException
-
- org.codehaus.jackson.map.JsonMappingException
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
UnrecognizedPropertyException
public class JsonMappingException extends 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
Nested Classes Modifier and Type Class Description static classJsonMappingException.ReferenceSimple bean class used to contain references.
-
Field Summary
Fields Modifier and Type Field Description protected LinkedList<JsonMappingException.Reference>_pathPath through which problem that triggering throwing of this exception was reached.-
Fields inherited from class org.codehaus.jackson.JsonProcessingException
mLocation
-
-
Constructor Summary
Constructors Constructor Description JsonMappingException(String msg)JsonMappingException(String msg, Throwable rootCause)JsonMappingException(String msg, JsonLocation loc)JsonMappingException(String msg, JsonLocation loc, Throwable rootCause)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_appendPathDesc(StringBuilder sb)static JsonMappingExceptionfrom(JsonParser jp, String msg)static JsonMappingExceptionfrom(JsonParser jp, String msg, Throwable problem)StringgetMessage()Method is overridden so that we can properly inject description of problem path, if such is defined.List<JsonMappingException.Reference>getPath()voidprependPath(Object referrer, int index)Method called to prepend a reference information in front of current pathvoidprependPath(Object referrer, String fieldName)Method called to prepend a reference information in front of current pathvoidprependPath(JsonMappingException.Reference r)StringtoString()static JsonMappingExceptionwrapWithPath(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 JsonMappingExceptionwrapWithPath(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.static JsonMappingExceptionwrapWithPath(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.-
Methods inherited from class org.codehaus.jackson.JsonProcessingException
getLocation
-
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
-
-
-
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, JsonLocation loc)
-
JsonMappingException
public JsonMappingException(String msg, JsonLocation loc, Throwable rootCause)
-
-
Method Detail
-
from
public static JsonMappingException from(JsonParser jp, String msg)
-
from
public static JsonMappingException from(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()
-
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)
-
getMessage
public String getMessage()
Method is overridden so that we can properly inject description of problem path, if such is defined.- Overrides:
getMessagein classJsonProcessingException
-
toString
public String toString()
- Overrides:
toStringin classJsonProcessingException
-
_appendPathDesc
protected void _appendPathDesc(StringBuilder sb)
-
-