Thanks to visit codestin.com
Credit goes to github.com

Skip to content

When a table is not found, the exception is swallowed up and null is returned #3930

@polleyg

Description

@polleyg

Environment details

  • OS: Mac (10.13.6)
  • Java version: 1.8.0_181
  • google-cloud-java version(s): 1.52.0

Steps to reproduce

  1. n/a
  2. n/a

Stacktrace

n/a

Code snippet

External references such as API reference guides used

Any additional information below

When a table is not found, null is returned instead of the actual HTTP code and BigQuery error message. This makes debugging much harder and is not intuitive for clients calling this method that null is actually returned when the table is not found. Instead, the exception should be propagated back up to the client so it can be handled accordingly.

@Override
  public Table getTable(String projectId, String datasetId, String tableId,
      Map<Option, ?> options) {
    try {
      return bigquery.tables()
          .get(projectId, datasetId, tableId)
          .setFields(Option.FIELDS.getString(options))
          .execute();
    } catch (IOException ex) {
      BigQueryException serviceException = translate(ex);
      if (serviceException.getCode() == HTTP_NOT_FOUND) {
        return null;
      }
      throw serviceException;
    }
  }

Metadata

Metadata

Assignees

Labels

api: bigqueryIssues related to the BigQuery API.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions