Java Code Examples for org.eclipse.lsp4j.jsonrpc.messages.ResponseError#setData()

The following examples show how to use org.eclipse.lsp4j.jsonrpc.messages.ResponseError#setData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RemoteEndpoint.java    From lsp4j with Eclipse Public License 2.0 6 votes vote down vote up
protected void handleRequestIssues(RequestMessage requestMessage, List<MessageIssue> issues) {
	ResponseError errorObject = new ResponseError();
	if (issues.size() == 1) {
		MessageIssue issue = issues.get(0);
		errorObject.setMessage(issue.getText());
		errorObject.setCode(issue.getIssueCode());
		errorObject.setData(issue.getCause());
	} else {
		if (requestMessage.getMethod() != null)
			errorObject.setMessage("Multiple issues were found in '" + requestMessage.getMethod() + "' request.");
		else
			errorObject.setMessage("Multiple issues were found in request.");
		errorObject.setCode(ResponseErrorCode.InvalidRequest);
		errorObject.setData(issues);
	}
	out.consume(createErrorResponseMessage(requestMessage, errorObject));
}
 
Example 2
Source File: ServerRefactoringIssueAcceptor.java    From xtext-core with Eclipse Public License 2.0 5 votes vote down vote up
public ResponseError toResponseError() {
	Severity maxSeverity = getMaximumSeverity();
	ResponseError responseError = new ResponseError();
	responseError.setMessage(getMessageBySeverity(maxSeverity));
	responseError.setCode(getCodeBySeverity(maxSeverity));
	List<Issue> bySeverity = IterableExtensions.sortBy(issues, (i) -> i.severity);
	List<String> messages = ListExtensions.map(ListExtensions.reverse(bySeverity), (i) -> i.message);
	responseError.setData(IterableExtensions.join(messages, "\n"));
	return responseError;
}
 
Example 3
Source File: RemoteEndpoint.java    From lsp4j with Eclipse Public License 2.0 5 votes vote down vote up
private static ResponseError fallbackResponseError(String header, Throwable throwable) {
	LOG.log(Level.SEVERE, header + ": " + throwable.getMessage(), throwable);
	ResponseError error = new ResponseError();
	error.setMessage(header + ".");
	error.setCode(ResponseErrorCode.InternalError);
	ByteArrayOutputStream stackTrace = new ByteArrayOutputStream();
	PrintWriter stackTraceWriter = new PrintWriter(stackTrace);
	throwable.printStackTrace(stackTraceWriter);
	stackTraceWriter.flush();
	error.setData(stackTrace.toString());
	return error;
}