Skip to content

Error reporting for failed quick fix - #685

Merged
mickaelistria merged 1 commit into
eclipse-lsp4e:masterfrom
BoykoAlex:quick-fix-error-dialog
Jun 6, 2023
Merged

mickaelistria merged 1 commit into
eclipse-lsp4e:masterfrom
BoykoAlex:quick-fix-error-dialog

Conversation

@BoykoAlex

Copy link
Copy Markdown
Contributor

Show error dialog if quick fix failed on the server side.

String errorMessage = "Failed to fetch quick fix edit for '" + codeAction.getTitle() //$NON-NLS-1$
+ "'. See Language Server '" + serverId + "' log for more details."; //$NON-NLS-1$ //$NON-NLS-2$
Display display = PlatformUI.getWorkbench().getDisplay();
display.asyncExec(() -> MessageDialog.openError(display.getActiveShell(), errorTitle, errorMessage));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rather use ServerMessageHandler.showMessage, as in other places in the codebase. Could you do that?

Comment on lines +104 to +105
Display display = PlatformUI.getWorkbench().getDisplay();
display.asyncExec(() -> MessageDialog.openError(display.getActiveShell(), errorTitle, errorMessage));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to have fun with newer constructs:

  .execute(ls -> ls.getWorkspaceService()
     .executeCommand(...)
     .exceptionally(this::constructErrorMessages()) // could be a Pair<String, String> or an Entry<String, String>
     .thenAcceptAsync(messages -> MessageDialog.openError(Display.getCurrent(), messages.getKey(), messages.getValue()), PlatformUI.getWorkbench().getDisplay())); // Display is now an Executor that can be used to "host" future chains

@BoykoAlex
BoykoAlex force-pushed the quick-fix-error-dialog branch from 4b17d93 to 6e2369b Compare June 6, 2023 17:36
@BoykoAlex

BoykoAlex commented Jun 6, 2023 •

Copy link
Copy Markdown
Contributor Author

@rubenporras @mickaelistria I have update the PR to address your comment. Thanks for the review :-) (Couldn't quite get the nice syntax for the future but something that is hopefully close enough)

@mickaelistria
mickaelistria merged commit 2b7ad0a into eclipse-lsp4e:master Jun 6, 2023
@mickaelistria

Copy link
Copy Markdown
Contributor

Thanks!

@rubenporras

Copy link
Copy Markdown
Contributor

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants