Skip to content

Throw InvalidFormatException instead of MismatchedInputException for ACCEPT_FLOAT_AS_INT coercion failures #2804

@mjustin

Description

@mjustin

I noticed that when ACCEPT_FLOAT_AS_INT is disabled, the application throws MismatchedInputException. It seems InvalidFormatException would be a good fit here, with the benefit of programmatically exposing the value that failed conversion.

I noticed this since I've added some custom handling in my application for InvalidFormatException/MismatchedInputException to provide terser/more user-appropriate errors. Since this scenario throws MismatchedInputException, I cannot programmatically retrieve the JSON value that failed to serialize. If it did implement InvalidFormatException, I could use InvalidFormatException.getValue() to get the value.

Note: This same reasoning applies to other similar features, such as ALLOW_COERCION_OF_SCALARS & FAIL_ON_NULL_FOR_PRIMITIVES.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions