mirror of
https://github.com/google/nomulus
synced 2026-05-25 09:10:51 +00:00
Account for GoogleJsonResponseException#getDetails returning null
Apparently, this can happen ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=223163802
This commit is contained in:
@@ -676,7 +676,7 @@ public class BigqueryConnection implements AutoCloseable {
|
||||
bigquery.datasets().get(getProjectId(), datasetName).execute();
|
||||
return true;
|
||||
} catch (GoogleJsonResponseException e) {
|
||||
if (e.getDetails().getCode() == 404) {
|
||||
if (e.getDetails() != null && e.getDetails().getCode() == 404) {
|
||||
return false;
|
||||
}
|
||||
throw e;
|
||||
@@ -689,7 +689,7 @@ public class BigqueryConnection implements AutoCloseable {
|
||||
bigquery.tables().get(getProjectId(), datasetName, tableName).execute();
|
||||
return true;
|
||||
} catch (GoogleJsonResponseException e) {
|
||||
if (e.getDetails().getCode() == 404) {
|
||||
if (e.getDetails() != null && e.getDetails().getCode() == 404) {
|
||||
return false;
|
||||
}
|
||||
throw e;
|
||||
|
||||
@@ -30,15 +30,20 @@ public final class BigqueryJobFailureException extends RuntimeException {
|
||||
/** Delegate {@link IOException} errors, checking for {@link GoogleJsonResponseException} */
|
||||
public static BigqueryJobFailureException create(IOException cause) {
|
||||
if (cause instanceof GoogleJsonResponseException) {
|
||||
return create(((GoogleJsonResponseException) cause).getDetails());
|
||||
return create((GoogleJsonResponseException) cause);
|
||||
} else {
|
||||
return new BigqueryJobFailureException(cause.getMessage(), cause, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/** Create an error for JSON server response errors. */
|
||||
public static BigqueryJobFailureException create(GoogleJsonError error) {
|
||||
return new BigqueryJobFailureException(error.getMessage(), null, null, error);
|
||||
public static BigqueryJobFailureException create(GoogleJsonResponseException cause) {
|
||||
GoogleJsonError err = cause.getDetails();
|
||||
if (err != null) {
|
||||
return new BigqueryJobFailureException(err.getMessage(), null, null, err);
|
||||
} else {
|
||||
return new BigqueryJobFailureException(cause.getMessage(), cause, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
/** Create an error from a failed job. */
|
||||
|
||||
Reference in New Issue
Block a user