Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@nonull could have surprising effects in error cases #3733

Closed
BoD opened this issue Dec 15, 2021 · 2 comments
Closed

@nonull could have surprising effects in error cases #3733

BoD opened this issue Dec 15, 2021 · 2 comments

Comments

@BoD
Copy link
Contributor

BoD commented Dec 15, 2021

When a nullable field is marked @nonnull locally, it of course can still be returned as null by the backend. In particular this can happen in case of partial errors.

When that happens, a JsonDataException will be thrown at JSON reading time, in the Adapter's fromJson method.

If we consider that this will probably happen in typical uses, this may be considered surprising to users.

  • Maybe it's only a matter of adding a warning in the documentation.
  • Or we could investigate a way to throw something less "low level" and more descriptive
@martinbonnin
Copy link
Contributor

Linking #2520 as it seems to be the same request.

Implementation wise, we could have a FailSafeAdapter(wrappedAdapter) that wraps another Adapter and catches errors to propagate them up the tree to the next nullable field. From that other issue, looks like error handling will be the difficult thing but certainly sounds doable.

@martinbonnin
Copy link
Contributor

This is addressed with #5405
Using @nullOnlyOnError is explicit that the errors may throw and must be handled with @catch if needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants