private static String message(IOException exception) { if (exception instanceof GoogleJsonResponseException) { GoogleJsonError details = ((GoogleJsonResponseException) exception).getDetails(); if (details != null) { return details.getMessage(); } } return exception.getMessage(); } }
@Override public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) { System.out.println("Error Message: " + e.getMessage()); } });
@Override public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) { System.out.println("Error Message: " + e.getMessage()); } };
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(); }
if ( gjre.getDetails() != null && gjre.getDetails().getMessage() != null ) { exceptionToDisplay = new IOException( gjre.getDetails().getMessage(), gjre );
public static Bucket createInProject(Storage storage, String project, Bucket bucket) throws IOException { try { Storage.Buckets.Insert insertBucket = storage.buckets().insert(project, bucket); return insertBucket.execute(); } catch (GoogleJsonResponseException e) { GoogleJsonError error = e.getDetails(); if (error != null && error.getCode() == HTTP_CONFLICT && error.getMessage().contains("You already own this bucket.")) { System.out.println("already exists"); return bucket; } System.err.println(error.getMessage()); throw e; } }
/** * Main demo. An Analytics service object is instantiated and then it is used to traverse and * print all the Management API entities. If any exceptions occur, they are caught and printed. * * @param args command line args. */ public static void main(String args[]) { try { HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR); Analytics analytics = initializeAnalytics(); printManagementEntities(analytics); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } catch (Throwable t) { t.printStackTrace(); } }
/** * Main demo. This first initializes an analytics service object. It then uses the Google * Analytics Management API to get the first profile ID for the authorized user. It then uses the * Core Reporting API to retrieve the top 25 organic search terms. Finally the results are printed * to the screen. If an API error occurs, it is printed here. * * @param args command line args. */ public static void main(String[] args) { try { httpTransport = GoogleNetHttpTransport.newTrustedTransport(); dataStoreFactory = new FileDataStoreFactory(DATA_STORE_DIR); Analytics analytics = initializeAnalytics(); String profileId = getFirstProfileId(analytics); if (profileId == null) { System.err.println("No profiles found."); } else { GaData gaData = executeDataQuery(analytics, profileId); printGaData(gaData); } } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } catch (Throwable t) { t.printStackTrace(); } }
/** * Main demo. This first initializes an analytics service object. It then uses the MCF API to * retrieve the top 25 source paths with most total conversions. It will also retrieve the top 25 * organic sources with most total conversions. Finally the results are printed to the screen. If * an API error occurs, it is printed here. * * @param args command line args. */ public static void main(String[] args) { try { HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR); Analytics analytics = initializeAnalytics(); McfData mcfPathData = executePathQuery(analytics, TABLE_ID); printAllInfo(mcfPathData); McfData mcfInteractionData = executeInteractionQuery(analytics, TABLE_ID); printAllInfo(mcfInteractionData); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } catch (Throwable t) { t.printStackTrace(); } }
/** * Main demo. This first initializes an Analytics service object. It then queries for the top 25 * organic search keywords and traffic sources by visits. Finally each important part of the * response is printed to the screen. * * @param args command line args. */ public static void main(String[] args) { try { HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport(); DATA_STORE_FACTORY = new FileDataStoreFactory(DATA_STORE_DIR); Analytics analytics = initializeAnalytics(); GaData gaData = executeDataQuery(analytics, TABLE_ID); printReportInfo(gaData); printProfileInfo(gaData); printQueryInfo(gaData); printPaginationInfo(gaData); printTotalsForAllResults(gaData); printColumnHeaders(gaData); printDataTable(gaData); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); } catch (Throwable t) { t.printStackTrace(); } }
System.err.println(error.getMessage());
@Override public void onFailure(GoogleJsonError error, HttpHeaders headers) throws IOException { ++failure; LOG.info("Failed to insert item: " + error.getMessage()); } }
private static String message(IOException exception) { if (exception instanceof GoogleJsonResponseException) { GoogleJsonError details = ((GoogleJsonResponseException) exception).getDetails(); if (details != null) { return details.getMessage(); } } return exception.getMessage(); } }
private static String message(IOException exception) { if (exception instanceof GoogleJsonResponseException) { GoogleJsonError details = ((GoogleJsonResponseException) exception).getDetails(); if (details != null) { return details.getMessage(); } } return exception.getMessage(); }
@Override public void onFailure(final GoogleJsonError e, final HttpHeaders responseHeaders) { log.warn(String.format("Failure deleting %s. %s", file, e.getMessage())); failures.add(new HttpResponseExceptionMappingService().map( new HttpResponseException(e.getCode(), e.getMessage()))); }
/** Extracts the error message. */ public String getErrorMessage(IOException e) { // Prefer to use message from GJRE. GoogleJsonResponseException gjre = getJsonResponseExceptionOrNull(e); if (gjre != null && gjre.getDetails() != null) { return gjre.getDetails().getMessage(); } return e.getMessage(); }
/** Extracts the error message. */ public String getErrorMessage(IOException e) { // Prefer to use message from GJRE. GoogleJsonResponseException gjre = getJsonResponseExceptionOrNull(e); if (gjre != null && gjre.getDetails() != null) { return gjre.getDetails().getMessage(); } return e.getMessage(); }
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; }
private static String resolveJsonResponseToMessage(GoogleJsonResponseException reason) { switch (reason.getStatusCode()) { case 403: return StackdriverDebuggerBundle.message("clouddebug.debug.targets.accessdenied"); default: return StackdriverDebuggerBundle.getString( "clouddebug.debug.targets.error", reason.getDetails().getMessage()); } }
public static List<Track> getTracks(App app) { try { Edits edits = init(app.getAppContext()).edits(); AppEdit edit = createEdit(app, edits); return edits.tracks().list(app.getApplicationId(), edit.getId()).execute().getTracks(); } catch (GoogleJsonResponseException ex) { throw new RuntimeException(ex.getDetails().getMessage(), ex); } catch (IOException ex) { throw new RuntimeException(ex); } }