Skip to content
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

Catch errors from any participants. #946

Closed
angelozerr opened this issue Dec 10, 2020 · 0 comments · Fixed by #947 or enxio/lsp4xml#100
Closed

Catch errors from any participants. #946

angelozerr opened this issue Dec 10, 2020 · 0 comments · Fixed by #947 or enxio/lsp4xml#100
Assignees
Labels
bug Something isn't working
Milestone

Comments

@angelozerr
Copy link
Contributor

angelozerr commented Dec 10, 2020

All participants like diagnostics, completions, etc loop for each participant and if one of participant throws an error, it breaks the other participants. For diagnostics case it seems that when a participant throw an error, the LSP publishDiagnostics is not traced in the console.

We should try catch each participant and log the error for each participant which throw an error.

For instance I suspect in #945 that there is this problem.

XMLDiagnostics should look like this:

class XMLDiagnostics {

	private static final Logger LOGGER = Logger.getLogger(XMLDiagnostics.class.getName());

	private final XMLExtensionsRegistry extensionsRegistry;

	public XMLDiagnostics(XMLExtensionsRegistry extensionsRegistry) {
		this.extensionsRegistry = extensionsRegistry;
	}

	public List<Diagnostic> doDiagnostics(DOMDocument xmlDocument, XMLValidationSettings validationSettings,
			CancelChecker cancelChecker) {
		List<Diagnostic> diagnostics = new ArrayList<Diagnostic>();
		if (validationSettings == null || validationSettings.isEnabled()) {
			doExtensionsDiagnostics(xmlDocument, diagnostics, validationSettings, cancelChecker);
		}
		return diagnostics;
	}

	private void doExtensionsDiagnostics(DOMDocument xmlDocument, List<Diagnostic> diagnostics,
			XMLValidationSettings validationSettings, CancelChecker monitor) {
		for (IDiagnosticsParticipant diagnosticsParticipant : extensionsRegistry.getDiagnosticsParticipants()) {
			monitor.checkCanceled();
			try {
				diagnosticsParticipant.doDiagnostics(xmlDocument, diagnostics, validationSettings, monitor);
			} catch (CancellationException e) {
				throw e;
			} catch (Exception e) {
				LOGGER.log(Level.SEVERE, "Error while processing diagnostics for the participant '"
						+ diagnosticsParticipant.getClass().getName() + "'.", e);
			}
		}
	}
}

It should be fine to:

  • do the same things for all participants.
  • write tests with a participant which throw an error.
@angelozerr angelozerr added the bug Something isn't working label Dec 10, 2020
@angelozerr angelozerr added this to the 0.15.0 milestone Dec 10, 2020
@datho7561 datho7561 self-assigned this Dec 10, 2020
datho7561 added a commit to datho7561/lemminx that referenced this issue Dec 10, 2020
Fixes eclipse#946

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/lemminx that referenced this issue Dec 15, 2020
Fixes eclipse#946

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/lemminx that referenced this issue Dec 16, 2020
Fixes eclipse#946

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/lemminx that referenced this issue Dec 16, 2020
Fixes eclipse#946

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/lemminx that referenced this issue Dec 17, 2020
Fixes eclipse#946

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/lemminx that referenced this issue Dec 17, 2020
Fixes eclipse#946

Signed-off-by: David Thompson <davthomp@redhat.com>
angelozerr pushed a commit that referenced this issue Dec 17, 2020
Fixes #946

Signed-off-by: David Thompson <davthomp@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants