- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
JacksonIOException,StreamConstraintsException,StreamReadException,StreamWriteException
Note that in Jackson 2.x this exception extended IOException
but in 3.x RuntimeException
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classSimple bean class used to contain references. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TokenStreamLocationprotected LinkedList<JacksonException.Reference>Path through which problem that triggering throwing of this exception was reached.protected CloseableUnderlying processor (JsonParserorJsonGenerator), if known. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJacksonException(Closeable processor, String msg) protectedJacksonException(Closeable processor, String msg, Throwable problem) protectedJacksonException(Closeable processor, String msg, TokenStreamLocation loc) protectedJacksonException(Closeable processor, String msg, TokenStreamLocation loc, Throwable rootCause) protectedJacksonException(Closeable processor, Throwable rootCause) protectedJacksonException(String msg) protectedJacksonException(String msg, Throwable rootCause) protectedJacksonException(String msg, TokenStreamLocation loc, Throwable rootCause) protectedJacksonException(Throwable rootCause) -
Method Summary
Modifier and TypeMethodDescriptionprotected StringBuilderprotected StringBuilderprotected StringDefault method overridden so that we can add location informationstatic StringMethod that allows to remove context information from this exception's message.Accessor for location information related to position within input or output (depending on operation), if available; if not available may returnTokenStreamLocation.NA(but nevernull).Method is overridden so that we can properly inject description of problem path, if such is defined.Method that allows accessing the original "message" argument, without additional decorations (like location information) that overriddengetMessage()adds.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 exceptionprotected StringAccessor that sub-classes can override to append additional information right after the main message, but before source location information.prependPath(Object referrer, int index) Method called to prepend a reference information in front of current pathprependPath(Object referrer, String propertyName) Method called to prepend a reference information in front of current pathMethod that allows accessing underlying processor that triggered this exception; typically eitherJsonParserorJsonGeneratorfor exceptions that originate from streaming API, but may be other types when thrown by databinding.toString()static JacksonExceptionwrapWithPath(Throwable src, Object refFrom, int index) Method that can be called to either create a newJacksonException(if underlying exception is not aJacksonException), or augment given exception with given path/reference information.static JacksonExceptionwrapWithPath(Throwable src, Object refFrom, String refPropertyName) Method that can be called to either create a newJacksonException(if underlying exception is not aJacksonException), or augment given exception with given path/reference information.static JacksonExceptionwrapWithPath(Throwable src, JacksonException.Reference ref) Method that can be called to either create a newJacksonException(if underlying exception is not aJacksonException), or augment given exception with given path/reference information.static JacksonExceptionwrapWithPath(Throwable src, JacksonException.Reference ref, BiFunction<String, Throwable, JacksonException> ctor) Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
_location
-
_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
-
-
Constructor Details
-
JacksonException
-
JacksonException
-
JacksonException
-
JacksonException
-
JacksonException
-
JacksonException
protected JacksonException(Closeable processor, String msg, TokenStreamLocation loc, Throwable rootCause) -
JacksonException
-
JacksonException
-
JacksonException
-
-
Method Details
-
withCause
-
clearLocation
Method that allows to remove context information from this exception's message. Useful when you are parsing security-sensitive data and don't want original data excerpts to be present in Jackson parser error messages.- Returns:
- This exception instance to allow call chaining
-
wrapWithPath
Method that can be called to either create a newJacksonException(if underlying exception is not aJacksonException), 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 newJacksonException(if underlying exception is not aJacksonException), 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 newJacksonException(if underlying exception is not aJacksonException), or augment given exception with given path/reference information. -
wrapWithPath
public static JacksonException wrapWithPath(Throwable src, JacksonException.Reference ref, BiFunction<String, Throwable, JacksonException> ctor) -
_exceptionMessage
-
prependPath
Method called to prepend a reference information in front of current path -
prependPath
Method called to prepend a reference information in front of current path -
prependPath
-
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
-
getLocation
Accessor for location information related to position within input or output (depending on operation), if available; if not available may returnTokenStreamLocation.NA(but nevernull).Accuracy of location information depends on backend (format) as well as (in some cases) operation being performed.
- Returns:
- Location in input or output that triggered the problem reported, if
available;
nullotherwise.
-
getOriginalMessage
Method that allows accessing the original "message" argument, without additional decorations (like location information) that overriddengetMessage()adds.- Returns:
- Original, unmodified
messageargument used to construct this exception instance
-
processor
Method that allows accessing underlying processor that triggered this exception; typically eitherJsonParserorJsonGeneratorfor exceptions that originate from streaming API, but may be other types when thrown by databinding.Note that it is possible that
nullmay be returned if code throwing exception either has no access to the 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.NOTE: In Jackson 2.x, accessor was
getProcessor(): in 3.0 changed to non-getter to avoid having to annotate for serialization.- Returns:
- Originating processor, if available;
nullif not.
-
messageSuffix
Accessor that sub-classes can override to append additional information right after the main message, but before source location information.NOTE: In Jackson 2.x, accessor was
getMessageSuffix(): in 3.0 changed to non-getter to indicate it is not a "regular" getter (although it would not be serialized anyway due to lower visibility).- Returns:
- Message suffix configured to be used, if any;
nullif none
-
getLocalizedMessage
- Overrides:
getLocalizedMessagein classThrowable
-
getMessage
Method is overridden so that we can properly inject description of problem path, if such is defined.- Overrides:
getMessagein classThrowable
-
_buildMessage
Default method overridden so that we can add location information- Returns:
- Message constructed based on possible optional prefix; explicit
messagepassed to constructor as well trailing location description (separate from message by linefeed)
-
toString
-
_appendReferenceChain
-
_appendPathDesc
-