In this code, I try to run a select on a table that doesn\'t exists, getJobReference()
returns NULL
and I would love to catch this kind of error, and w
Their API automatically creates some classes on fly, and errors are eaten on creation.
I ended up after a debug process to get errors like this:
try {
$job = $bq->jobs->insert(PROJECT_ID, $job);
$status = new Google_Service_Bigquery_JobStatus();
$status = $job->getStatus();
// print_r($status);
if ($status->count() != 0) {
$err_res = $status->getErrorResult();
die($err_res->getMessage());
}
} catch (Google_Service_Exception $e) {
echo $e->getMessage();
exit;
}
The general way is to see if there is a Status
class for the service you are using. The Exception block gets activated only when errors are thrown, and that is when dryRun
is active.
$config->setDryRun(true);
I don't know this SDK very well, but did you check if you get an exception?
try {
$insert = new Google_Service_Bigquery_Job($bq->jobs->insert(PROJECT_ID, $job));
}
catch (Exception $e) //or probably better Google_Exception
{
print('Something went wrong');
}