Sunday, 1 September 2013

How to handle BigQuery errors in Java environment

How to handle BigQuery errors in Java environment

We are trying to find the most reliable way how to handle errors returned
by BigQuery Java client in our app. In case of any error the client
returns an instance of
com.google.api.client.googleapis.json.GoogleJsonResponseException.
The only way how to distinguish between different types of errors, we have
found so far, is to use returned status code and detail messages. It means
that we have to somehow parse String messages. But this is not very clear
and even worse it is dependent on the String messages that can change in
future releases.
Please see example below.
bigquery.tables().get(projectNumber, datasetId, tableId).execute();
If such a dataset or table is not found, we get the exception with status
code 404. OK, we know that something was not found, however, if we need to
know what exactly was not found (dataset or table), we have to parse
provided error messages.
We would expect e.g. different exceptions for different errors to be
thrown and with such details like datasetId (in case of a dataset not
found error) in its own property so we can use it and do not have to
extract it from a string.
Did we miss something or this is really the only way at the moment?

No comments:

Post a Comment