Skip to content

Commit

Permalink
bigquery: check for apiResponse presence (#1853)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenplusplus committed Dec 2, 2016
1 parent 978b1f5 commit 61b04a1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/bigquery/src/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Job.prototype.getQueryResultsStream = function(options) {
*/
Job.prototype.poll_ = function(callback) {
this.getMetadata(function(err, metadata, apiResponse) {
if (apiResponse.status && apiResponse.status.errors) {
if (!err && apiResponse.status && apiResponse.status.errors) {
err = common.util.ApiError(apiResponse.status);
}

Expand Down
3 changes: 1 addition & 2 deletions packages/bigquery/test/job.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,10 @@ describe('BigQuery/Job', function() {

describe('API error', function() {
var error = new Error('Error.');
var apiResponse = {};

beforeEach(function() {
job.getMetadata = function(callback) {
callback(error, null, apiResponse);
callback(error);
};
});

Expand Down

0 comments on commit 61b04a1

Please sign in to comment.