InputCoercionException (Jackson-core 2.11.0 API)
Date: 2020-04-25

com.fasterxml.jackson.core.exc

## Class InputCoercionException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.io.IOException
      - - com.fasterxml.jackson.core.JsonProcessingException
        - - com.fasterxml.jackson.core.exc.StreamReadException
          - - com.fasterxml.jackson.core.exc.InputCoercionException

- All Implemented Interfaces:
    Serializable

      public class InputCoercionException
      extends StreamReadException

  Exception type for read-side problems that are not direct decoding ("parsing") problems (those would be reported as `JsonParseException`s), but rather result from failed attempts to convert specific Java value out of valid but incompatible input value. One example is numeric coercions where target number type's range does not allow mapping of too large/too small input value.
  Since:
    2.10
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected JsonToken` | `_inputType` Input token that represents input value that failed to coerce.
    `protected Class<?>` | `_targetType` Target type that input value failed to coerce to.

    - ### Fields inherited from class com.fasterxml.jackson.core.exc.StreamReadException

      `_processor, _requestPayload`

    - ### Fields inherited from class com.fasterxml.jackson.core.JsonProcessingException

      `_location`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `InputCoercionException(JsonParser p, String msg, JsonToken inputType, Class<?> targetType)` Constructor that uses current parsing location as location, and sets processor (accessible via `StreamReadException.getProcessor()`) to specified parser.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `JsonToken` | `getInputType()` Accessor for getting information about input type (in form of token, giving "shape" of input) for which coercion failed.
    `Class<?>` | `getTargetType()` Accessor for getting information about target type (in form of Java `Class`) for which coercion failed.
    `InputCoercionException` | `withParser(JsonParser p)` Fluent method that may be used to assign originating `JsonParser`, to be accessed using `StreamReadException.getProcessor()`.
    `InputCoercionException` | `withRequestPayload(RequestPayload p)` Fluent method that may be used to assign payload to this exception, to let recipient access it for diagnostics purposes.

    - ### Methods inherited from class com.fasterxml.jackson.core.exc.StreamReadException

      `getMessage, getProcessor, getRequestPayload, getRequestPayloadAsString`

    - ### Methods inherited from class com.fasterxml.jackson.core.JsonProcessingException

      `clearLocation, getLocation, getMessageSuffix, getOriginalMessage, toString`

    - ### Methods inherited from class java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### _inputType

          protected final JsonToken _inputType

      Input token that represents input value that failed to coerce.

    - #### _targetType

          protected final Class<?> _targetType

      Target type that input value failed to coerce to.

  - ### Constructor Detail

    - #### InputCoercionException

          public InputCoercionException(JsonParser p,
                                        String msg,
                                        JsonToken inputType,
                                        Class<?> targetType)

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

  - ### Method Detail

    - #### withParser

          public InputCoercionException withParser(JsonParser p)

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

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

      Specified by:
        `withParser` in class `StreamReadException`

    - #### withRequestPayload

          public InputCoercionException withRequestPayload(RequestPayload p)

      Description copied from class: `StreamReadException`
      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.

      Specified by:
        `withRequestPayload` in class `StreamReadException`

    - #### getInputType

          public JsonToken getInputType()

      Accessor for getting information about input type (in form of token, giving "shape" of input) for which coercion failed.

    - #### getTargetType

          public Class<?> getTargetType()

      Accessor for getting information about target type (in form of Java `Class`) for which coercion failed.

Copyright © 2008–2020 FasterXML. All rights reserved.