This issue could just as well be posted to the ObjectMapper repo, but I thought I'd post it here nonetheless, since it affects this project as well.
Scenario
Given an endpoint that returns say a list of photo objects that are all ImmutableMappable, if any one of them fails to deserialize, the whole response is treated as a failure and an error is thrown. This is due to ImmutableMappable.mapArray(). While it does a compactMap like its Mappable counterpart, it throws in addition. Thus, it's behaviour differs, in that with Mappable, those particular objects would simply be evicted from the response array.
Question
Is there a reason for the existing approach or is it a bug?
Proposed Solution
Make the behaviour match Mappable by catching errors and simply returning nil (which would get filtered out by the compactMap). I believe this is the behaviour most users would want/expect. If all the objects fail to deserialize, you'll simply have an empty array response.
In effect, the change would be something like this (in ObjectMapper - would need to change the other variants as well):
First off, thanks for the great project!
This issue could just as well be posted to the ObjectMapper repo, but I thought I'd post it here nonetheless, since it affects this project as well.
Scenario
Given an endpoint that returns say a list of photo objects that are all
ImmutableMappable
, if any one of them fails to deserialize, the whole response is treated as a failure and an error is thrown. This is due toImmutableMappable.mapArray()
. While it does acompactMap
like itsMappable
counterpart, itthrows
in addition. Thus, it's behaviour differs, in that withMappable
, those particular objects would simply be evicted from the response array.Question
Is there a reason for the existing approach or is it a bug?
Proposed Solution
Make the behaviour match
Mappable
by catching errors and simply returningnil
(which would get filtered out by thecompactMap
). I believe this is the behaviour most users would want/expect. If all the objects fail to deserialize, you'll simply have an empty array response.In effect, the change would be something like this (in ObjectMapper - would need to change the other variants as well):