-
Notifications
You must be signed in to change notification settings - Fork 148
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
Unwrap InvocationTargetException which are ResponseErrorException #809
Conversation
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.
@jonahgraham This looks like a nice improvement indeed, thank you! 👍
It seems that the documentation update in #578 needs to be reverted or amended now, either as part of this PR or a follow-up.
d2925a4
to
4c49a57
Compare
I updated docs and updated tests. New commit was used to update description of the PR |
There is one todo thing left, hence turned to draft, the code change when it is delegate segments has no test coverage. Probably also worth adding to changelog. |
org.eclipse.lsp4j.jsonrpc/src/main/java/org/eclipse/lsp4j/jsonrpc/services/GenericEndpoint.java
Outdated
Show resolved
Hide resolved
By wrapping ResponseErrorException with another layer in RuntimeException it means the unwrapping of the exception in RemoteEndpoint.DEFAULT_EXCEPTION_HANDLER doesn't work as expected and instead of getting the original ResponseError the other end gets the fallback ResponseError of type internal error. This change includes updates to documentation to show that it is ok to throw ResponseErrorException (reverts #578). While it is also OK to return an exceptionally completed future, it is not needed to do that way and simply throwing is more straightforward. There are new tests to cover the changed handling. Also tested is the previously documented way of handling exceptions (see `tries == 1` case in `testVersatility` and `testVersatilityResponseError` Fixes #802 Also-by: Vladimir Piskarev <[email protected]>
This exception is thrown when the endpoint is created, not as a result of a receiving a message. This is generally a coding error, so make this exception the same as the other exceptions thrown by recursiveFindRpcMethods. Included is adding additional tests to ensure coverage of some previously missing uses cases. Code cleanup done as part of #802
706d14b
to
aa0bb9e
Compare
Newest commit adds to the changelog. It also adds the code coverage as the find delegate's change I had done previously was incorrect. |
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 good, thanks for the fix 👍
org.eclipse.lsp4j.jsonrpc/src/main/java/org/eclipse/lsp4j/jsonrpc/services/GenericEndpoint.java
Outdated
Show resolved
Hide resolved
See #809 (comment) for detailed discussion.
The 'sneaky throws' change is ready for review: 4de6734 :-) |
I have another approach in the works, which does not use sneaky throws. It is based on the fact that an |
Checked exceptions should not be thrown from annotated jsonrpc methods. Such exceptions can be treated as a programming error, and signaled via an IllegalStateException in the GenericEndpoint. An inaccessible jsonrpc method can be handled in a similar way. For detailed discussion and context, see #809 (comment).
4de6734
to
3982fd3
Compare
The latest change is ready for review: 3982fd3. |
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.
(Silly GitHub - I can't approve my own PR even though I am reviewing @pisv's latest change)
+1 on this change.
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.
Given that @jonahgraham has approved my latest change, this PR is complete and ready to be merged, as far as I can tell.
Thank you @jonahgraham and @ivy-cst!
@ivy-cst this change should end up on snapshot builds soon: https://github.com/eclipse-lsp4j/lsp4j?tab=readme-ov-file#snapshots Please comment in #807 if you have input on if/when a full release will help your adoption so that I can consider how and when to make a release. |
Thank you for the fix. We do not need a release. We are currently living with our own exception handler. We are tied to the eclipse rcp releases at the moment anyway. |
OK thanks for responding - if that changes please comment on #807 PS I really appreciate that you followed up on this issue, especially knowing that it did not affect your code in the short term. It will now make everyone's code in the future better and is part of what makes me very happy to be working on open source projects with a vibrant community! |
By wrapping ResponseErrorException with another layer in RuntimeException it means the unwrapping of the exception in RemoteEndpoint.DEFAULT_EXCEPTION_HANDLER doesn't work as expected and instead of getting the original ResponseError the other end gets the fallback ResponseError of type internal error.
This change includes updates to documentation to show that it is ok to throw ResponseErrorException (reverts #578). While it is also OK to return an exceptionally completed future, it is not needed to do that way and simply throwing is more straightforward.
There are new tests to cover the changed handling. Also tested is the previously documented way of handling exceptions (see
tries == 1
case intestVersatility
andtestVersatilityResponseError
Fixes #802