-
Notifications
You must be signed in to change notification settings - Fork 62
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
Add inProcessExecution that propagates the conjure exceptions #1516
Conversation
Generate changelog in
|
if (ex == null) { | ||
thrownException = Optional.ofNullable(ex); |
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 one seems suspect - ex
is null here, so we probably don't need this line.
? handleJsonMappingException((JsonMappingException) exception) | ||
: exception.getMessage()) | ||
.collect(Collectors.joining("\n")); | ||
commandLine.getErr().println(message); |
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.
What happens to this when called in process? Does it still print out to stderr?
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.
Looks like there is a setErr
we can use on CommandLine
to change it.
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.
@VisibleForTesting | ||
static CommandLine prepareCommand() { | ||
return new CommandLine(new ConjureCli()).setExecutionExceptionHandler(new ExceptionHandler()); | ||
} | ||
|
||
public static final class ExceptionHandler implements IExecutionExceptionHandler { | ||
|
||
private Optional<Exception> thrownException = Optional.empty(); |
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.
I actually think we can write this a little more concisely/safely for future changes. We can keep the existing IExecutionExceptionHandler
as is then write a wrapper IExecutionExceptionHandler
that wraps the original one but catches the exception and saves it. Also sets the err
and if that is written to, we make an exception from that.
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.
Perhaps with a TeeOutputStream
to the original err
if we want to preserve the current behaviour (maybe we don't need to though?)
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.
added a separate class that does the exception wrapping here: https://github.com/palantir/conjure/pull/1516/files#diff-cc1e8eaeed51e87c5b283c659588f4c2f976ceafdc8ad587e89fc92460fdccedR33.
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.
Nice!
2057ae9
to
e840abf
Compare
Released 4.40.0 |
Before this PR
Conjure exceptions were not propagated to gradle-conjure. We were only getting the
exitCode
.before the exception looked like:
After this PR
Introduces a new
inProcessExecution
method that will re-throw any exception==COMMIT_MSG==
Add inProcessExecution that propagates the conjure exceptions
==COMMIT_MSG==
Possible downsides?