Java 类org.eclipse.lsp4j.jsonrpc.ResponseErrorException 实例源码
项目:SOMns-vscode
文件:GenericEndpoint.java
@Override
public CompletableFuture<?> request(String method, Object parameter) {
Function<Object, CompletableFuture<Object>> handler = methodHandlers.get(method);
if (handler != null) {
return handler.apply(parameter);
}
if (delegate instanceof Endpoint) {
return ((Endpoint) delegate).request(method, parameter);
}
String message = "Unsupported request method: " + method;
if (isOptionalMethod(method)) {
LOG.log(Level.INFO, message);
return CompletableFuture.completedFuture(null);
}
LOG.log(Level.WARNING, message);
CompletableFuture<?> exceptionalResult = new CompletableFuture<Object>();
ResponseError error = new ResponseError(ResponseErrorCode.MethodNotFound, message, null);
exceptionalResult.completeExceptionally(new ResponseErrorException(error));
return exceptionalResult;
}
项目:lsp4j
文件:GenericEndpoint.java
@Override
public CompletableFuture<?> request(String method, Object parameter) {
Function<Object, CompletableFuture<Object>> handler = methodHandlers.get(method);
if (handler != null) {
return handler.apply(parameter);
}
if (delegate instanceof Endpoint) {
return ((Endpoint) delegate).request(method, parameter);
}
String message = "Unsupported request method: " + method;
if (isOptionalMethod(method)) {
LOG.log(Level.INFO, message);
return CompletableFuture.completedFuture(null);
}
LOG.log(Level.WARNING, message);
CompletableFuture<?> exceptionalResult = new CompletableFuture<Object>();
ResponseError error = new ResponseError(ResponseErrorCode.MethodNotFound, message, null);
exceptionalResult.completeExceptionally(new ResponseErrorException(error));
return exceptionalResult;
}
项目:eclipse.jdt.ls
文件:WorkspaceExecuteCommandHandlerTest.java
@Test
public void testExecuteCommandNonexistingCommand() {
expectedEx.expect(ResponseErrorException.class);
expectedEx.expectMessage("No delegateCommandHandler for testcommand.not.existing");
WorkspaceExecuteCommandHandler handler = new WorkspaceExecuteCommandHandler();
ExecuteCommandParams params = new ExecuteCommandParams();
params.setCommand("testcommand.not.existing");
params.setArguments(Arrays.asList("hello", "world"));
Object result = handler.executeCommand(params, monitor);
}
项目:eclipse.jdt.ls
文件:WorkspaceExecuteCommandHandlerTest.java
@Test
public void testExecuteCommandThrowsExceptionCommand() {
expectedEx.expect(ResponseErrorException.class);
expectedEx.expectMessage("Unsupported");
WorkspaceExecuteCommandHandler handler = new WorkspaceExecuteCommandHandler();
ExecuteCommandParams params = new ExecuteCommandParams();
params.setCommand("testcommand.throwexception");
handler.executeCommand(params, monitor);
}
项目:eclipse.jdt.ls
文件:WorkspaceExecuteCommandHandlerTest.java
@Test
public void testExecuteCommandInvalidParameters() {
expectedEx.expect(ResponseErrorException.class);
expectedEx.expectMessage("The workspace/executeCommand has empty params or command");
WorkspaceExecuteCommandHandler handler = new WorkspaceExecuteCommandHandler();
ExecuteCommandParams params = null;
handler.executeCommand(params, monitor);
}
项目:xtext-core
文件:ServerRefactoringIssueAcceptor.java
public void checkSeverity() {
RefactoringIssueAcceptor.Severity _maximumSeverity = this.getMaximumSeverity();
boolean _lessThan = (_maximumSeverity.compareTo(RefactoringIssueAcceptor.Severity.WARNING) < 0);
if (_lessThan) {
ResponseError _responseError = this.toResponseError();
throw new ResponseErrorException(_responseError);
}
}
项目:xtext-core
文件:WorkspaceManager.java
protected IWorkspaceConfig getWorkspaceConfig() {
if ((this._workspaceConfig == null)) {
final ResponseError error = new ResponseError(ResponseErrorCode.serverNotInitialized,
"Workspace has not been initialized yet.", null);
throw new ResponseErrorException(error);
}
return this._workspaceConfig;
}