Search in sources :

Example 1 with GoogleJsonErrorContainer

use of com.google.api.client.googleapis.json.GoogleJsonErrorContainer in project beam by apache.

the class BigQueryServicesImplTest method errorWithReasonAndStatus.

/**
 * A helper that generates the error JSON payload that Google APIs produce.
 */
private static GoogleJsonErrorContainer errorWithReasonAndStatus(String reason, int status) {
    ErrorInfo info = new ErrorInfo();
    info.setReason(reason);
    info.setDomain("global");
    // GoogleJsonError contains one or more ErrorInfo objects; our utiities read the first one.
    GoogleJsonError error = new GoogleJsonError();
    error.setErrors(ImmutableList.of(info));
    error.setCode(status);
    error.setMessage(reason);
    // The actual JSON response is an error container.
    GoogleJsonErrorContainer container = new GoogleJsonErrorContainer();
    container.setError(error);
    return container;
}
Also used : ErrorInfo(com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo) GoogleJsonErrorContainer(com.google.api.client.googleapis.json.GoogleJsonErrorContainer) GoogleJsonError(com.google.api.client.googleapis.json.GoogleJsonError)

Aggregations

GoogleJsonError (com.google.api.client.googleapis.json.GoogleJsonError)1 ErrorInfo (com.google.api.client.googleapis.json.GoogleJsonError.ErrorInfo)1 GoogleJsonErrorContainer (com.google.api.client.googleapis.json.GoogleJsonErrorContainer)1