private static ExceptionData makeExceptionData( GoogleJsonError googleJsonError, boolean idempotent, Set<BaseServiceException.Error> retryableErrors) { int code = googleJsonError.getCode(); String reason = reason(googleJsonError); ExceptionData.Builder exceptionData = ExceptionData.newBuilder(); exceptionData .setMessage(googleJsonError.getMessage()) .setCause(null) .setRetryable(BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors)) .setCode(code) .setReason(reason); if (reason != null) { GoogleJsonError.ErrorInfo errorInfo = googleJsonError.getErrors().get(0); exceptionData.setLocation(errorInfo.getLocation()); exceptionData.setDebugInfo((String) errorInfo.get("debugInfo")); } else { exceptionData.setLocation(null); exceptionData.setDebugInfo(null); } return exceptionData.build(); }
retryable = error.isRetryable(idempotent, retryableErrors); if (reason != null) { GoogleJsonError.ErrorInfo errorInfo = jsonError.getErrors().get(0); location = errorInfo.getLocation(); debugInfo = (String) errorInfo.get("debugInfo");
List<ErrorInfo> errors = e.getDetails().getErrors(); for (ErrorInfo error : errors) { if (error.getReason().equals("noAdSenseAccount")) {
/** * Get the first ErrorInfo from a GoogleJsonError, or null if * there is not one. */ protected ErrorInfo getErrorInfo(GoogleJsonError details) { if (details == null) { return null; } List<ErrorInfo> errors = details.getErrors(); return errors.isEmpty() ? null : errors.get(0); }
/** * Get the first ErrorInfo from a GoogleJsonError, or null if * there is not one. */ protected ErrorInfo getErrorInfo(GoogleJsonError details) { if (details == null) { return null; } List<ErrorInfo> errors = details.getErrors(); return errors.isEmpty() ? null : errors.get(0); }
response = adminApi.sslCerts().createEphemeral(projectId, instanceName, req).execute(); } catch (GoogleJsonResponseException e) { if (e.getDetails() == null || e.getDetails().getErrors().isEmpty()) { throw new RuntimeException( String reason = e.getDetails().getErrors().get(0).getReason(); if (INSTANCE_NOT_AUTHORIZED_REASON.equals(reason)) { String who = "you have";
response = adminApi.sslCerts().createEphemeral(projectId, instanceName, req).execute(); } catch (GoogleJsonResponseException e) { if (e.getDetails() == null || e.getDetails().getErrors().isEmpty()) { throw new RuntimeException( String reason = e.getDetails().getErrors().get(0).getReason(); if (INSTANCE_NOT_AUTHORIZED_REASON.equals(reason)) { String who = "you have";
public BatchResponse<T> addError(GoogleJsonError error) { this.errors.addAll(error.getErrors()); this.resultBuilder.addItem(BulkItem.<T>builder() .setSuccessful(false) .setStatusCode(String.valueOf(error.getCode())) .setMessage(error.getMessage()) ); return this; }
instance = adminApi.instances().get(projectId, instanceName).execute(); } catch (GoogleJsonResponseException e) { if (e.getDetails() == null || e.getDetails().getErrors().isEmpty()) { throw new RuntimeException( String reason = e.getDetails().getErrors().get(0).getReason(); if (ADMIN_API_NOT_ENABLED_REASON.equals(reason)) { String apiLink =
instance = adminApi.instances().get(projectId, instanceName).execute(); } catch (GoogleJsonResponseException e) { if (e.getDetails() == null || e.getDetails().getErrors().isEmpty()) { throw new RuntimeException( String reason = e.getDetails().getErrors().get(0).getReason(); if (ADMIN_API_NOT_ENABLED_REASON.equals(reason)) { String apiLink =
public BaseServiceException(GoogleJsonError googleJsonError, boolean idempotent) { super(googleJsonError.getMessage()); Error error = new Error(googleJsonError.getCode(), reason(googleJsonError)); this.code = error.code; this.reason = error.reason; this.retryable = isRetryable(idempotent, error); if (this.reason != null) { GoogleJsonError.ErrorInfo errorInfo = googleJsonError.getErrors().get(0); this.location = errorInfo.getLocation(); this.debugInfo = (String) errorInfo.get("debugInfo"); } else { this.location = null; this.debugInfo = null; } this.idempotent = idempotent; }
@Override public BackgroundException map(final IOException failure) { final StringBuilder buffer = new StringBuilder(); if(failure instanceof GoogleJsonResponseException) { final GoogleJsonResponseException error = (GoogleJsonResponseException) failure; this.append(buffer, error.getDetails().getMessage()); switch(error.getDetails().getCode()) { case HttpStatus.SC_FORBIDDEN: final List<GoogleJsonError.ErrorInfo> errors = error.getDetails().getErrors(); for(GoogleJsonError.ErrorInfo info : errors) { if("usageLimits".equals(info.getDomain())) { return new RetriableAccessDeniedException(buffer.toString(), Duration.ofSeconds(5), failure); } } break; } } if(failure instanceof HttpResponseException) { final HttpResponseException response = (HttpResponseException) failure; this.append(buffer, response.getStatusMessage()); return new HttpResponseExceptionMappingService().map(new org.apache.http.client .HttpResponseException(response.getStatusCode(), buffer.toString())); } return super.map(failure); } }
return; if (!e1.getDetails().getErrors().get(0).getReason().equals("resourceNotReady")) { throw e1;
public BaseServiceException(IOException exception, boolean idempotent) { super(message(exception), exception); int code = UNKNOWN_CODE; String reason = null; String location = null; String debugInfo = null; Boolean retryable = null; if (exception instanceof GoogleJsonResponseException) { GoogleJsonError jsonError = ((GoogleJsonResponseException) exception).getDetails(); if (jsonError != null) { Error error = new Error(jsonError.getCode(), reason(jsonError)); code = error.code; reason = error.reason; retryable = isRetryable(idempotent, error); if (reason != null) { GoogleJsonError.ErrorInfo errorInfo = jsonError.getErrors().get(0); location = errorInfo.getLocation(); debugInfo = (String) errorInfo.get("debugInfo"); } } else { code = ((GoogleJsonResponseException) exception).getStatusCode(); } } this.retryable = MoreObjects.firstNonNull(retryable, isRetryable(idempotent, exception)); this.code = code; this.reason = reason; this.idempotent = idempotent; this.location = location; this.debugInfo = debugInfo; }
private static ExceptionData makeExceptionData( GoogleJsonError googleJsonError, boolean idempotent, Set<BaseServiceException.Error> retryableErrors) { int code = googleJsonError.getCode(); String reason = reason(googleJsonError); ExceptionData.Builder exceptionData = ExceptionData.newBuilder(); exceptionData .setMessage(googleJsonError.getMessage()) .setCause(null) .setRetryable(BaseServiceException.isRetryable(code, reason, idempotent, retryableErrors)) .setCode(code) .setReason(reason); if (reason != null) { GoogleJsonError.ErrorInfo errorInfo = googleJsonError.getErrors().get(0); exceptionData.setLocation(errorInfo.getLocation()); exceptionData.setDebugInfo((String) errorInfo.get("debugInfo")); } else { exceptionData.setLocation(null); exceptionData.setDebugInfo(null); } return exceptionData.build(); }
retryable = error.isRetryable(idempotent, retryableErrors); if (reason != null) { GoogleJsonError.ErrorInfo errorInfo = jsonError.getErrors().get(0); location = errorInfo.getLocation(); debugInfo = (String) errorInfo.get("debugInfo");