Java Code Examples for com.google.api.services.compute.model.Operation#getError()
The following examples show how to use
com.google.api.services.compute.model.Operation#getError() .
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: GoogleProviderUtils.java From halyard with Apache License 2.0 | 6 votes |
private static void waitOnOperation(Supplier<Operation> operationSupplier) { Operation operation = operationSupplier.get(); while (!operation.getStatus().equals("DONE")) { if (operation.getError() != null) { throw new HalException( FATAL, String.join( "\n", operation.getError().getErrors().stream() .map(e -> e.getCode() + ": " + e.getMessage()) .collect(Collectors.toList()))); } operation = operationSupplier.get(); DaemonTaskHandler.safeSleep(TimeUnit.SECONDS.toMillis(1)); } }
Example 2
Source File: GcpStackUtil.java From cloudbreak with Apache License 2.0 | 6 votes |
private static String checkForErrors(Operation operation) { if (operation == null) { LOGGER.info("Operation is null!"); return null; } String msg = null; if (operation.getError() != null) { StringBuilder error = new StringBuilder(); if (operation.getError().getErrors() != null) { for (Errors errors : operation.getError().getErrors()) { error.append(String.format("code: %s -> message: %s %s", errors.getCode(), errors.getMessage(), System.lineSeparator())); } msg = error.toString(); } else { LOGGER.debug("No errors found, Error: {}", operation.getError()); } } if (operation.getHttpErrorStatusCode() != null) { msg += String.format(" HTTP error message: %s, HTTP error status code: %s", operation.getHttpErrorMessage(), operation.getHttpErrorStatusCode()); } return msg; }
Example 3
Source File: GcpInstanceResourceBuilder.java From cloudbreak with Apache License 2.0 | 5 votes |
private void verifyOperation(Operation operation, List<CloudResource> buildableResource) { if (operation.getHttpErrorStatusCode() != null) { throw new GcpResourceException(operation.getHttpErrorMessage(), resourceType(), buildableResource.get(0).getName()); } if (operation.getError() != null && !operation.getError().isEmpty()) { throw new GcpResourceException(operation.getError().getErrors().stream() .map(Operation.Error.Errors::getMessage).collect(Collectors.joining(",")), resourceType(), buildableResource.get(0).getName()); } }
Example 4
Source File: GcpResourceChecker.java From cloudbreak with Apache License 2.0 | 5 votes |
private void checkError(Operation execute) { if (execute.getError() != null) { String msg = null; StringBuilder error = new StringBuilder(); if (execute.getError().getErrors() != null) { for (Operation.Error.Errors errors : execute.getError().getErrors()) { error.append(String.format("code: %s -> message: %s %s", errors.getCode(), errors.getMessage(), System.lineSeparator())); } msg = error.toString(); } throw new CloudConnectorException(msg); } }