eclipse-lsp4j / lsp4j

A Java implementation of the language server protocol intended to be consumed by tools and language servers implemented in Java.
https://eclipse.org/lsp4j
Other
613 stars 145 forks source link

Pass more informative `Throwable` from handler invocations #703

Closed cmoon4799 closed 1 year ago

cmoon4799 commented 1 year ago

RemoteEndpoint.java - as it stands, a Throwable, deriving from an InvocationTargetException from GenericEndpoint.recursiveFindRpcMethods, passed into RemoteEndpoint.exceptionHandler will not be handled as an InvocationTargetException. With this change, a custom exceptionHandler will at least be able to use the Throwable message that was thrown from the invoked handler.

For example, suppose I have a debug server with a RPC method Foo within which an Exception is thrown with message custom string. Once Foo is invoked and throws an Exception, exceptionHandler will obtain a RuntimeException (from recursiveFindRpcMethods) with little connection to the thrown Exception - AFAIU, the custom message can only be obtained by parsing the stack trace which may be cumbersome. This change will allow a custom exceptionHandler to easily read from Throwable.message instead.

eclipse-lsp4j-bot commented 1 year ago

Can one of the admins verify this patch?

jonahgraham commented 1 year ago

Thank you @cmoon4799 for the PR. I think @szarnekow's review probably covers things as for how the change is now. Do you want to provide a PR that better traverses the exceptions in the DEFAULT_EXCEPTION_HANDLER?

PS To accept PRs we need a signed ECA.

jonahgraham commented 1 year ago

I am closing this now due to lack of activity and lack of ECA. @cmoon4799 feel free to reopen if you want to address any of the review comments.