Top Description Fields Constructors Methods
com.fasterxml.jackson.core

public Class JsonParseException

extends StreamReadException
Class Inheritance
Known Direct Subclasses
com.fasterxml.jackson.core.io.JsonEOFException
Imports
com.fasterxml.jackson.core.exc.StreamReadException, com.fasterxml.jackson.core.util.RequestPayload

Exception type for parsing problems, used when non-well-formed content (content that does not conform to JSON syntax as per specification) is encountered.

Field Summary

Modifier and TypeField and Description
private static final long
Inherited from com.fasterxml.jackson.core.exc.StreamReadException:
_processor_requestPayload

Constructor Summary

AccessConstructor and Description
public
public
JsonParseException(JsonParser
Parser in use when encountering issue reported
p
,
String
Base exception message to use
msg
)

Constructor that uses current parsing location as location, and sets processor (accessible via getProcessor()) to specified parser.

public
public
public
public
JsonParseException(String msg, JsonLocation loc)
Deprecated

public
JsonParseException(String msg, JsonLocation loc, Throwable rootCause)
Deprecated

Method Summary

Modifier and TypeMethod and Description
public String
getMessage()

Overrides com.fasterxml.jackson.core.exc.StreamReadException.getMessage.

Overriding the getMessage() to include the request body

public JsonParser
getProcessor()

Overrides com.fasterxml.jackson.core.exc.StreamReadException.getProcessor.

Method that allows accessing underlying processor that triggered this exception; typically either JsonParser or JsonGenerator for exceptions that originate from streaming API.

public RequestPayload
getRequestPayload()

Overrides com.fasterxml.jackson.core.exc.StreamReadException.getRequestPayload.

Method that may be called to find payload that was being parsed, if one was specified for parser that threw this Exception.

public String
getRequestPayloadAsString()

Overrides com.fasterxml.jackson.core.exc.StreamReadException.getRequestPayloadAsString.

The method returns the String representation of the request payload if one was specified for parser that threw this Exception.

public JsonParseException

Returns:

This exception instance to allow call chaining
withParser
(JsonParser
Parser instance to assign to this exception
p
)

Implements abstract com.fasterxml.jackson.core.exc.StreamReadException.withParser.

Fluent method that may be used to assign originating JsonParser, to be accessed using getProcessor().

public JsonParseException

Returns:

This exception instance to allow call chaining
withRequestPayload
(RequestPayload
Payload to assign to this exception
payload
)

Implements abstract com.fasterxml.jackson.core.exc.StreamReadException.withRequestPayload.

Fluent method that may be used to assign payload to this exception, to let recipient access it for diagnostics purposes.

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides com.fasterxml.jackson.core.exc.StreamReadException.serialVersionUID.

Constructor Detail

JsonParseExceptionback to summary
public JsonParseException(String msg)
JsonParseExceptionback to summary
public JsonParseException(JsonParser p, String msg)

Constructor that uses current parsing location as location, and sets processor (accessible via getProcessor()) to specified parser.

Parameters
p:JsonParser

Parser in use when encountering issue reported

msg:String

Base exception message to use

Since
2.7
JsonParseExceptionback to summary
public JsonParseException(JsonParser p, String msg, Throwable rootCause)
JsonParseExceptionback to summary
public JsonParseException(JsonParser p, String msg, JsonLocation loc)
JsonParseExceptionback to summary
public JsonParseException(JsonParser p, String msg, JsonLocation loc, Throwable rootCause)
JsonParseExceptionback to summary
public JsonParseException(String msg, JsonLocation loc)

Deprecated

Annotations
@Deprecated
JsonParseExceptionback to summary
public JsonParseException(String msg, JsonLocation loc, Throwable rootCause)

Deprecated

Annotations
@Deprecated

Method Detail

getMessageback to summary
public String getMessage()

Overrides com.fasterxml.jackson.core.exc.StreamReadException.getMessage.

Doc from com.fasterxml.jackson.core.exc.StreamReadException.getMessage.

Overriding the getMessage() to include the request body

Returns:String

Doc from com.fasterxml.jackson.core.JsonProcessingException.getMessage.

Original message preceded by optional prefix and followed by location information, message and location information separated by a linefeed

Annotations
@Override
getProcessorback to summary
public JsonParser getProcessor()

Overrides com.fasterxml.jackson.core.exc.StreamReadException.getProcessor.

Doc from com.fasterxml.jackson.core.JsonProcessingException.getProcessor.

Method that allows accessing underlying processor that triggered this exception; typically either JsonParser or JsonGenerator for 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.

Returns:JsonParser

Originating processor, if available; null if not.

Annotations
@Override
getRequestPayloadback to summary
public RequestPayload getRequestPayload()

Overrides com.fasterxml.jackson.core.exc.StreamReadException.getRequestPayload.

Doc from com.fasterxml.jackson.core.exc.StreamReadException.getRequestPayload.

Method that may be called to find payload that was being parsed, if one was specified for parser that threw this Exception.

Returns:RequestPayload

request body, if payload was specified; `null` otherwise

Annotations
@Override
getRequestPayloadAsStringback to summary
public String getRequestPayloadAsString()

Overrides com.fasterxml.jackson.core.exc.StreamReadException.getRequestPayloadAsString.

Doc from com.fasterxml.jackson.core.exc.StreamReadException.getRequestPayloadAsString.

The method returns the String representation of the request payload if one was specified for parser that threw this Exception.

Returns:String

request body as String, if payload was specified; `null` otherwise

Annotations
@Override
withParserback to summary
public JsonParseException withParser(JsonParser p)

Implements abstract com.fasterxml.jackson.core.exc.StreamReadException.withParser.

Fluent method that may be used to assign originating JsonParser, to be accessed using getProcessor().

Note

`this` instance is modified and no new instance is constructed.

Parameters
p:JsonParser

Parser instance to assign to this exception

Returns:JsonParseException

This exception instance to allow call chaining

Annotations
@Override
Since
2.7
withRequestPayloadback to summary
public JsonParseException withRequestPayload(RequestPayload payload)

Implements abstract com.fasterxml.jackson.core.exc.StreamReadException.withRequestPayload.

Fluent method that may be used to assign payload to this exception, to let recipient access it for diagnostics purposes.

Note

`this` instance is modified and no new instance is constructed.

Parameters
payload:RequestPayload

Payload to assign to this exception

Returns:JsonParseException

This exception instance to allow call chaining

Annotations
@Override
Since
2.8