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

Discussion: Stop Optional Fields from throwing exceptions #412

Open
RichardWarburton opened this issue Nov 25, 2020 · 0 comments
Open

Discussion: Stop Optional Fields from throwing exceptions #412

RichardWarburton opened this issue Nov 25, 2020 · 0 comments

Comments

@RichardWarburton
Copy link
Contributor

At the moment if you have a missing value for a field in an Artio decoder after a decode then:

(1) if the field is required then validation will fail and a missing sentinel value like: MISSING_FLOAT will be returned from the accessor.
(2) if the field is optional then validation will pass and an exception like new IllegalArgumentException("No value for optional field: OrderQty"); will be thrown by the accessor.

There is a proposal to change the behaviour of (2) so that instead of throwing an exception it would return the MISSING sentinel value. Validation would still object to a missing required field but not a missing optional field as that's what optional means.

This has the advantage of simplifying codec usage by making behaviour more consistent and simplifying generation by removing some special casing. It is a change of behaviour that's subtle in the sense of not breaking an API. I'd like to solicit feedback as to whether anyone has strong objections to this change or you're ok with it?

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

No branches or pull requests

1 participant