-
Notifications
You must be signed in to change notification settings - Fork 220
aggregate exception improvement #1188
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
Conversation
private final List<Exception> causes; | ||
|
||
public AggregatedOperatorException(String message, Exception... exceptions) { | ||
super(message); | ||
this.causes = exceptions != null ? Arrays.asList(exceptions) : Collections.emptyList(); | ||
super(message, exceptions[0]); |
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.
This might NPE if no exception is passed.
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.
pushed with null check
} | ||
|
||
public AggregatedOperatorException(String message, List<Exception> exceptions) { | ||
super(message); | ||
this.causes = exceptions != null ? exceptions : Collections.emptyList(); | ||
super(message, exceptions.get(0)); |
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.
Same, we need to check that the given parameter is not null…
|
||
public class AggregatedOperatorException extends OperatorException { | ||
|
||
private final List<Exception> causes; | ||
|
||
public AggregatedOperatorException(String message, Exception... exceptions) { | ||
super(message, exceptions[0]); | ||
super(message, Objects.requireNonNull(exceptions)[0]); |
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.
That doesn't help, actually, since this still will throw an NPE if exceptions
isn't present. With varargs, it's a definite possibility, though, granted, creating an AggregatedOperatorException
and not passing any exceptions is probably expected to fail…
Kudos, SonarCloud Quality Gate passed! |
Overriding
toString
. Adding the first exception as cause - maybe would be better to overrideprintStackTrace
to handle the causes? RespectivelygetOurStackTrace
inThrowable
to have it nicer?