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:
Serializable
- Direct Known Subclasses:
InvalidDefinitionException,MismatchedInputException,UnresolvedForwardReference,ValueInstantiationException
Checked exception used to signal fatal problems with mapping of
content, distinct from low-level I/O problems (signaled using
simple
IOExceptions) or data encoding/decoding
problems (signaled with StreamReadException,
StreamWriteException).
One additional feature is the ability to denote relevant path of references (during serialization/deserialization) to help in troubleshooting.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple bean class used to contain references. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LinkedList<JsonMappingException.Reference>Path through which problem that triggering throwing of this exception was reached.protected CloseableUnderlying processor (JsonParserorJsonGenerator), if known.Fields inherited from class com.fasterxml.jackson.core.JsonProcessingException
_location -
Constructor Summary
ConstructorsConstructorDescriptionJsonMappingException(Closeable processor, String msg) JsonMappingException(Closeable processor, String msg, JsonLocation loc) JsonMappingException(Closeable processor, String msg, Throwable problem) Deprecated.JsonMappingException(String msg, JsonLocation loc) Deprecated.Since 2.7 Use variant that takesJsonParserinsteadJsonMappingException(String msg, JsonLocation loc, Throwable rootCause) Deprecated.Since 2.7 Use variant that takesJsonParserinsteadJsonMappingException(String msg, Throwable rootCause) Deprecated.Since 2.7 Use variant that takesJsonParserinstead -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected StringBuilderMethod that is called to add reference chain information to message, but may be overridden to customize handling, including appending other information or removing the reference chain altogether.protected Stringstatic JsonMappingExceptionfrom(JsonGenerator g, String msg) static JsonMappingExceptionfrom(JsonGenerator g, String msg, Throwable problem) static JsonMappingExceptionfrom(JsonParser p, String msg) static JsonMappingExceptionfrom(JsonParser p, String msg, Throwable problem) static JsonMappingExceptionfrom(DeserializationContext ctxt, String msg) static JsonMappingExceptionfrom(DeserializationContext ctxt, String msg, Throwable t) static JsonMappingExceptionfrom(SerializerProvider ctxt, String msg) static JsonMappingExceptionfrom(SerializerProvider ctxt, String msg, Throwable problem) static JsonMappingExceptionFactory method used when "upgrading" anIOExceptionintoJsonMappingException: usually only needed to comply with a signature.Method is overridden so that we can properly inject description of problem path, if such is defined.getPath()Method for accessing full structural path within type hierarchy down to problematic property.Method for accessing description of path that lead to the problem that triggered this exceptionMethod that allows accessing underlying processor that triggered this exception; typically eitherJsonParserorJsonGeneratorfor exceptions that originate from streaming API.voidvoidprependPath(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 pathtoString()static JsonMappingExceptionMethod 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, 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.Methods inherited from class com.fasterxml.jackson.core.JsonProcessingException
clearLocation, getLocation, getMessageSuffix, getOriginalMessageMethods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
_path
Path through which problem that triggering throwing of this exception was reached. -
_processor
Underlying processor (JsonParserorJsonGenerator), if known.NOTE: typically not serializable hence
transient- Since:
- 2.7
-
-
Constructor Details
-
JsonMappingException
Deprecated.Since 2.7 Use variant that takesJsonParserinstead -
JsonMappingException
Deprecated.Since 2.7 Use variant that takesJsonParserinstead -
JsonMappingException
Deprecated.Since 2.7 Use variant that takesJsonParserinstead -
JsonMappingException
Deprecated.Since 2.7 Use variant that takesJsonParserinstead -
JsonMappingException
- Since:
- 2.7
-
JsonMappingException
- Since:
- 2.7
-
JsonMappingException
- Since:
- 2.7
-
-
Method Details
-
from
- Since:
- 2.7
-
from
- Since:
- 2.7
-
from
- Since:
- 2.7
-
from
- Since:
- 2.7
-
from
- Since:
- 2.7
-
from
- Since:
- 2.7
-
from
- Since:
- 2.7
-
from
- Since:
- 2.7
-
fromUnexpectedIOE
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
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
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
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
- Since:
- 2.13
-
getPath
Method for accessing full structural path within type hierarchy down to problematic property. -
getPathReference
Method for accessing description of path that lead to the problem that triggered this exception -
getPathReference
-
prependPath
Method called to prepend a reference information in front of current path- Specified by:
prependPathin classDatabindException
-
prependPath
Method called to prepend a reference information in front of current path- Specified by:
prependPathin classDatabindException
-
prependPath
-
getProcessor
Description copied from class:JsonProcessingExceptionMethod that allows accessing underlying processor that triggered this exception; typically eitherJsonParserorJsonGeneratorfor exceptions that originate from streaming API. Note that it is possible that `null` may be returned if code throwing exception either has no access to processor; or has not been retrofitted to set it; this means that caller needs to take care to check for nulls. Subtypes override this method with co-variant return type, for more type-safe access.- Overrides:
getProcessorin classJsonProcessingException- Returns:
- Originating processor, if available; null if not.
-
getLocalizedMessage
- Overrides:
getLocalizedMessagein classThrowable
-
getMessage
Method is overridden so that we can properly inject description of problem path, if such is defined.- Overrides:
getMessagein classJsonProcessingException- Returns:
- Original
messagepreceded by optional prefix and followed by location information, message and location information separated by a linefeed
-
_buildMessage
-
toString
- Overrides:
toStringin classJsonProcessingException
-
_appendReferenceChain
Method that is called to add reference chain information to message, but may be overridden to customize handling, including appending other information or removing the reference chain altogether.- Since:
- 2.18.2
-
_appendPathDesc
-
JsonParserinstead