-
Notifications
You must be signed in to change notification settings - Fork 2
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
Java: Throw RuntimeException when a condition isn't met #376
Conversation
Note: in addition to the changes introduced by this PR, the diff includes unreleased changes living in
grafana-foundation-sdk@next+cog-v0.0.x |
Can you post a before-after diff of the generated java files? I have trouble reviewing these PRs without examples |
if (id >= 5) { | ||
return this; | ||
if (!(id >= 5)) { | ||
throw new RuntimeException("id must be >= 5"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: These feel more like IllegalArgumentException
: https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalArgumentException.html which is a subclass of RuntimeException
Thanks for the diff! |
Contributes to #360
The easiest way to archive this is throwing a
RuntimeException
when a condition isn't met. With this we delegate the exception management to the user.It also negates all constraints conditions because it was wrong 😅.