Package com.fasterxml.jackson.databind
Class JsonMappingException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.io.IOException
-
- com.fasterxml.jackson.core.JacksonException
-
- com.fasterxml.jackson.core.JsonProcessingException
-
- com.fasterxml.jackson.databind.DatabindException
-
- com.fasterxml.jackson.databind.JsonMappingException
-
- All Implemented Interfaces:
java.io.Serializable
- Direct Known Subclasses:
InvalidDefinitionException,MismatchedInputException,UnresolvedForwardReference,ValueInstantiationException
public class JsonMappingException extends DatabindException
Checked exception used to signal fatal problems with mapping of content, distinct from low-level I/O problems (signaled using simpleIOExceptions) or data encoding/decoding problems (signaled withStreamReadException,StreamWriteException).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 java.util.LinkedList<JsonMappingException.Reference>_pathPath through which problem that triggering throwing of this exception was reached.protected java.io.Closeable_processorUnderlying processor (JsonParserorJsonGenerator), if known.
-
Constructor Summary
Constructors Constructor Description JsonMappingException(java.io.Closeable processor, java.lang.String msg)JsonMappingException(java.io.Closeable processor, java.lang.String msg, com.fasterxml.jackson.core.JsonLocation loc)JsonMappingException(java.io.Closeable processor, java.lang.String msg, java.lang.Throwable problem)JsonMappingException(java.lang.String msg)Deprecated.Since 2.7 Use variant that takesJsonParserinsteadJsonMappingException(java.lang.String msg, com.fasterxml.jackson.core.JsonLocation loc)Deprecated.Since 2.7 Use variant that takesJsonParserinsteadJsonMappingException(java.lang.String msg, com.fasterxml.jackson.core.JsonLocation loc, java.lang.Throwable rootCause)Deprecated.Since 2.7 Use variant that takesJsonParserinsteadJsonMappingException(java.lang.String msg, java.lang.Throwable rootCause)Deprecated.Since 2.7 Use variant that takesJsonParserinstead
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void_appendPathDesc(java.lang.StringBuilder sb)protected java.lang.String_buildMessage()static JsonMappingExceptionfrom(com.fasterxml.jackson.core.JsonGenerator g, java.lang.String msg)static JsonMappingExceptionfrom(com.fasterxml.jackson.core.JsonGenerator g, java.lang.String msg, java.lang.Throwable problem)static JsonMappingExceptionfrom(com.fasterxml.jackson.core.JsonParser p, java.lang.String msg)static JsonMappingExceptionfrom(com.fasterxml.jackson.core.JsonParser p, java.lang.String msg, java.lang.Throwable problem)static JsonMappingExceptionfrom(DeserializationContext ctxt, java.lang.String msg)static JsonMappingExceptionfrom(DeserializationContext ctxt, java.lang.String msg, java.lang.Throwable t)static JsonMappingExceptionfrom(SerializerProvider ctxt, java.lang.String msg)static JsonMappingExceptionfrom(SerializerProvider ctxt, java.lang.String msg, java.lang.Throwable problem)static JsonMappingExceptionfromUnexpectedIOE(java.io.IOException src)Factory method used when "upgrading" anIOExceptionintoJsonMappingException: usually only needed to comply with a signature.java.lang.StringgetLocalizedMessage()java.lang.StringgetMessage()Method is overridden so that we can properly inject description of problem path, if such is defined.java.util.List<JsonMappingException.Reference>getPath()Method for accessing full structural path within type hierarchy down to problematic property.java.lang.StringgetPathReference()Method for accessing description of path that lead to the problem that triggered this exceptionjava.lang.StringBuildergetPathReference(java.lang.StringBuilder sb)java.lang.ObjectgetProcessor()voidprependPath(JsonMappingException.Reference r)voidprependPath(java.lang.Object referrer, int index)Method called to prepend a reference information in front of current pathvoidprependPath(java.lang.Object referrer, java.lang.String fieldName)Method called to prepend a reference information in front of current pathjava.lang.StringtoString()JsonMappingExceptionwithCause(java.lang.Throwable cause)static JsonMappingExceptionwrapWithPath(java.lang.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 JsonMappingExceptionwrapWithPath(java.lang.Throwable src, java.lang.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(java.lang.Throwable src, java.lang.Object refFrom, java.lang.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
clearLocation, getLocation, getMessageSuffix, getOriginalMessage
-
-
-
-
Field Detail
-
_path
protected java.util.LinkedList<JsonMappingException.Reference> _path
Path through which problem that triggering throwing of this exception was reached.
-
_processor
protected transient java.io.Closeable _processor
Underlying processor (JsonParserorJsonGenerator), if known.NOTE: typically not serializable hence
transient- Since:
- 2.7
-
-
Constructor Detail
-
JsonMappingException
@Deprecated public JsonMappingException(java.lang.String msg)
Deprecated.Since 2.7 Use variant that takesJsonParserinstead
-
JsonMappingException
@Deprecated public JsonMappingException(java.lang.String msg, java.lang.Throwable rootCause)Deprecated.Since 2.7 Use variant that takesJsonParserinstead
-
JsonMappingException
@Deprecated public JsonMappingException(java.lang.String msg, com.fasterxml.jackson.core.JsonLocation loc)Deprecated.Since 2.7 Use variant that takesJsonParserinstead
-
JsonMappingException
@Deprecated public JsonMappingException(java.lang.String msg, com.fasterxml.jackson.core.JsonLocation loc, java.lang.Throwable rootCause)Deprecated.Since 2.7 Use variant that takesJsonParserinstead
-
JsonMappingException
public JsonMappingException(java.io.Closeable processor, java.lang.String msg)- Since:
- 2.7
-
JsonMappingException
public JsonMappingException(java.io.Closeable processor, java.lang.String msg, java.lang.Throwable problem)- Since:
- 2.7
-
JsonMappingException
public JsonMappingException(java.io.Closeable processor, java.lang.String msg, com.fasterxml.jackson.core.JsonLocation loc)- Since:
- 2.7
-
-
Method Detail
-
from
public static JsonMappingException from(com.fasterxml.jackson.core.JsonParser p, java.lang.String msg)
- Since:
- 2.7
-
from
public static JsonMappingException from(com.fasterxml.jackson.core.JsonParser p, java.lang.String msg, java.lang.Throwable problem)
- Since:
- 2.7
-
from
public static JsonMappingException from(com.fasterxml.jackson.core.JsonGenerator g, java.lang.String msg)
- Since:
- 2.7
-
from
public static JsonMappingException from(com.fasterxml.jackson.core.JsonGenerator g, java.lang.String msg, java.lang.Throwable problem)
- Since:
- 2.7
-
from
public static JsonMappingException from(DeserializationContext ctxt, java.lang.String msg)
- Since:
- 2.7
-
from
public static JsonMappingException from(DeserializationContext ctxt, java.lang.String msg, java.lang.Throwable t)
- Since:
- 2.7
-
from
public static JsonMappingException from(SerializerProvider ctxt, java.lang.String msg)
- Since:
- 2.7
-
from
public static JsonMappingException from(SerializerProvider ctxt, java.lang.String msg, java.lang.Throwable problem)
- Since:
- 2.7
-
fromUnexpectedIOE
public static JsonMappingException fromUnexpectedIOE(java.io.IOException src)
Factory method used when "upgrading" anIOExceptionintoJsonMappingException: usually only needed to comply with a signature.NOTE: since 2.9 should usually NOT be used on input-side (deserialization) exceptions; instead use method(s) of
InputMismatchException- Since:
- 2.1
-
wrapWithPath
public static JsonMappingException wrapWithPath(java.lang.Throwable src, java.lang.Object refFrom, java.lang.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(java.lang.Throwable src, java.lang.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(java.lang.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.
-
withCause
public JsonMappingException withCause(java.lang.Throwable cause)
- Since:
- 2.13
-
getPath
public java.util.List<JsonMappingException.Reference> getPath()
Method for accessing full structural path within type hierarchy down to problematic property.
-
getPathReference
public java.lang.String getPathReference()
Method for accessing description of path that lead to the problem that triggered this exception
-
getPathReference
public java.lang.StringBuilder getPathReference(java.lang.StringBuilder sb)
-
prependPath
public void prependPath(java.lang.Object referrer, java.lang.String fieldName)Method called to prepend a reference information in front of current path- Specified by:
prependPathin classDatabindException
-
prependPath
public void prependPath(java.lang.Object referrer, int index)Method called to prepend a reference information in front of current path- Specified by:
prependPathin classDatabindException
-
prependPath
public void prependPath(JsonMappingException.Reference r)
-
getProcessor
public java.lang.Object getProcessor()
- Overrides:
getProcessorin classcom.fasterxml.jackson.core.JsonProcessingException
-
getLocalizedMessage
public java.lang.String getLocalizedMessage()
- Overrides:
getLocalizedMessagein classjava.lang.Throwable
-
getMessage
public java.lang.String getMessage()
Method is overridden so that we can properly inject description of problem path, if such is defined.- Overrides:
getMessagein classcom.fasterxml.jackson.core.JsonProcessingException
-
_buildMessage
protected java.lang.String _buildMessage()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classcom.fasterxml.jackson.core.JsonProcessingException
-
_appendPathDesc
protected void _appendPathDesc(java.lang.StringBuilder sb)
-
-