Or consider InvalidNullException?
Its doc says...

/**
 * Exception thrown if a `null` value is being encountered for a property
 * designed as "fail on null" property (see {@link
com.fasterxml.jackson.annotation.JsonSetter}).
 *
 * @since 2.9
 */
public class InvalidNullException


On Sat, Mar 22, 2025 at 7:43 AM Sandeep Gaur <sandeep.gaur...@gmail.com>
wrote:

> Hi,
>
> If I understand your problem correctly, IllegalArgumentException would be
> the most appropriate choice because null is a valid response from
> readValue. The additional restriction is being imposed by the client,
> making IllegalArgumentException the right fit for enforcing this
> constraints.
>
> Thanks,
> Sandeep gaur
>
>
>
> On Sat, 22 Mar, 2025, 12:39 am wrongwrong, <boranti1...@gmail.com> wrote:
>
>> Hello everyone, I'm looking for advice on implementation in kotlin-module.
>>
>> The ObjectMapper.readValue may return null as a result.
>> On the other hand, in the kotlin-module extension, if the user calls
>> readValue expecting non-null, an error should be thrown if the result is
>> null(https://github.com/FasterXML/jackson-module-kotlin/issues/399).
>>
>> I have learned how to achieve this, but am struggling with which
>> exception should be thrown as a validation error.
>>
>> 1. NPE
>> 2. some exception defined in Jackson (what would be appropriate?)
>> 3. any proprietary exception in kotlin-module
>>
>> Personally, I think 2 is better, but is there any appropriate exception?
>> Any advice would be appreciated.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "jackson-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to jackson-dev+unsubscr...@googlegroups.com.
>> To view this discussion visit
>> https://groups.google.com/d/msgid/jackson-dev/1dbee532-1337-46f2-b81c-563503656aa8n%40googlegroups.com
>> <https://groups.google.com/d/msgid/jackson-dev/1dbee532-1337-46f2-b81c-563503656aa8n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "jackson-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jackson-dev+unsubscr...@googlegroups.com.
> To view this discussion visit
> https://groups.google.com/d/msgid/jackson-dev/CAOddboJ5Q-za4Ncy5kiM1%2Bn%3D9_sVzd%2BOeLWNFwSs5FpNGAXdPw%40mail.gmail.com
> <https://groups.google.com/d/msgid/jackson-dev/CAOddboJ5Q-za4Ncy5kiM1%2Bn%3D9_sVzd%2BOeLWNFwSs5FpNGAXdPw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/jackson-dev/CALS-ipwYyqQDQXFXm3k3CUGvs4rJYXTX6%3DYzG3o7ykCCd2V9qg%40mail.gmail.com.

Reply via email to