Class 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 JsonParseExceptions), 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:
  • Field Details

    • _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 Details

    • 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.
      Parameters:
      p - Parser in use at the point where failure occurred
      msg - Exception mesage to use
      inputType - Shape of input that failed to coerce
      targetType - Target type of failed coercion
  • Method Details

    • 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
      Parameters:
      p - Parser instance to assign to this exception
      Returns:
      This exception instance to allow call chaining
    • 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
      Parameters:
      p - Payload to assign to this exception
      Returns:
      This exception instance to allow call chaining
    • getInputType

      public JsonToken getInputType()
      Accessor for getting information about input type (in form of token, giving "shape" of input) for which coercion failed.
      Returns:
      "Shape" of input for which coercion failed, as JsonToken
    • getTargetType

      public Class<?> getTargetType()
      Accessor for getting information about target type (in form of Java Class) for which coercion failed.
      Returns:
      Target type of failed conversion