public class JsonMappingException extends DatabindException
IOException
s) 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.
Modifier and Type | Class and Description |
---|---|
static class |
JsonMappingException.Reference
Simple bean class used to contain references.
|
Modifier and Type | Field and Description |
---|---|
protected LinkedList<JsonMappingException.Reference> |
_path
Path through which problem that triggering throwing of
this exception was reached.
|
protected Closeable |
_processor
Underlying processor (
JsonParser or JsonGenerator ),
if known. |
Constructor and Description |
---|
JsonMappingException(Closeable processor,
String msg) |
JsonMappingException(Closeable processor,
String msg,
com.fasterxml.jackson.core.JsonLocation loc) |
JsonMappingException(Closeable processor,
String msg,
Throwable problem) |
JsonMappingException(String msg)
Deprecated.
Since 2.7 Use variant that takes
JsonParser instead |
JsonMappingException(String msg,
com.fasterxml.jackson.core.JsonLocation loc)
Deprecated.
Since 2.7 Use variant that takes
JsonParser instead |
JsonMappingException(String msg,
com.fasterxml.jackson.core.JsonLocation loc,
Throwable rootCause)
Deprecated.
Since 2.7 Use variant that takes
JsonParser instead |
JsonMappingException(String msg,
Throwable rootCause)
Deprecated.
Since 2.7 Use variant that takes
JsonParser instead |
Modifier and Type | Method and Description |
---|---|
protected void |
_appendPathDesc(StringBuilder sb) |
protected String |
_buildMessage() |
static JsonMappingException |
from(DeserializationContext ctxt,
String msg) |
static JsonMappingException |
from(DeserializationContext ctxt,
String msg,
Throwable t) |
static JsonMappingException |
from(com.fasterxml.jackson.core.JsonGenerator g,
String msg) |
static JsonMappingException |
from(com.fasterxml.jackson.core.JsonGenerator g,
String msg,
Throwable problem) |
static JsonMappingException |
from(com.fasterxml.jackson.core.JsonParser p,
String msg) |
static JsonMappingException |
from(com.fasterxml.jackson.core.JsonParser p,
String msg,
Throwable problem) |
static JsonMappingException |
from(SerializerProvider ctxt,
String msg) |
static JsonMappingException |
from(SerializerProvider ctxt,
String msg,
Throwable problem) |
static JsonMappingException |
fromUnexpectedIOE(IOException src)
Factory method used when "upgrading" an
IOException into
JsonMappingException : usually only needed to comply with
a signature. |
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 accessing description of path that lead to the
problem that triggered this exception
|
StringBuilder |
getPathReference(StringBuilder sb) |
Object |
getProcessor() |
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() |
JsonMappingException |
withCause(Throwable cause) |
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.
|
clearLocation, getLocation, getMessageSuffix, getOriginalMessage
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
protected LinkedList<JsonMappingException.Reference> _path
protected transient Closeable _processor
JsonParser
or JsonGenerator
),
if known.
NOTE: typically not serializable hence transient
@Deprecated public JsonMappingException(String msg)
JsonParser
instead@Deprecated public JsonMappingException(String msg, Throwable rootCause)
JsonParser
instead@Deprecated public JsonMappingException(String msg, com.fasterxml.jackson.core.JsonLocation loc)
JsonParser
instead@Deprecated public JsonMappingException(String msg, com.fasterxml.jackson.core.JsonLocation loc, Throwable rootCause)
JsonParser
insteadpublic JsonMappingException(Closeable processor, String msg, Throwable problem)
public static JsonMappingException from(com.fasterxml.jackson.core.JsonParser p, String msg)
public static JsonMappingException from(com.fasterxml.jackson.core.JsonParser p, String msg, Throwable problem)
public static JsonMappingException from(com.fasterxml.jackson.core.JsonGenerator g, String msg)
public static JsonMappingException from(com.fasterxml.jackson.core.JsonGenerator g, String msg, Throwable problem)
public static JsonMappingException from(DeserializationContext ctxt, String msg)
public static JsonMappingException from(DeserializationContext ctxt, String msg, Throwable t)
public static JsonMappingException from(SerializerProvider ctxt, String msg)
public static JsonMappingException from(SerializerProvider ctxt, String msg, Throwable problem)
public static JsonMappingException fromUnexpectedIOE(IOException src)
IOException
into
JsonMappingException
: 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
public static JsonMappingException wrapWithPath(Throwable src, Object refFrom, String refFieldName)
public static JsonMappingException wrapWithPath(Throwable src, Object refFrom, int index)
public static JsonMappingException wrapWithPath(Throwable src, JsonMappingException.Reference ref)
public JsonMappingException withCause(Throwable cause)
public List<JsonMappingException.Reference> getPath()
public String getPathReference()
public StringBuilder getPathReference(StringBuilder sb)
public void prependPath(Object referrer, String fieldName)
prependPath
in class DatabindException
public void prependPath(Object referrer, int index)
prependPath
in class DatabindException
public void prependPath(JsonMappingException.Reference r)
public Object getProcessor()
getProcessor
in class com.fasterxml.jackson.core.JsonProcessingException
public String getLocalizedMessage()
getLocalizedMessage
in class Throwable
public String getMessage()
getMessage
in class com.fasterxml.jackson.core.JsonProcessingException
protected String _buildMessage()
public String toString()
toString
in class com.fasterxml.jackson.core.JsonProcessingException
protected void _appendPathDesc(StringBuilder sb)
Copyright © 2008–2022 FasterXML. All rights reserved.