OK, I have created an isssue. https://github.com/FasterXML/jackson-module-kotlin/issues/934
Please reply to the discussion here. 2025年3月22日土曜日 14:53:33 UTC+9 Joo Hyuk Kim: > I would like to suggest bring this to GH discussion for more ideas. > > 2025년 3월 22일 (토) 오후 2:50, wrongwrong <boran...@gmail.com>님이 작성: > >> Thank you all for the replies. >> >> > If I understand your problem correctly, IllegalArgumentException would >> be the most appropriate choice because null is a valid response >> from readValue. >> >> In edge cases, the return value of readValue may not be valid. >> Since ObjectMapper can be inherited, it is possible that null will be >> returned due to an implementation error. >> It is even possible that an invalid value is returned. >> >> Personally, I feel that IllegalArgumentException may not be the way to go >> in such cases. >> >> > Or consider InvalidNullException? >> >> I initially thought this would be better, but had the above concerns. >> Would the more abstract JsonMappingException be more appropriate? >> >> 2025年3月22日土曜日 11:32:12 UTC+9 Joo Hyuk Kim: >> >>> 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...@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, <boran...@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...@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...@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...@googlegroups.com. >> > To view this discussion visit >> https://groups.google.com/d/msgid/jackson-dev/838c3c9c-9584-4728-b9b1-569d61be071bn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/jackson-dev/838c3c9c-9584-4728-b9b1-569d61be071bn%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/e812899a-0e5e-4b34-9fd5-35b692ae7a5dn%40googlegroups.com.