How to troubleshoot/get error response when you run invalid BigQuery jobs?

别等时光非礼了梦想. 提交于 2019-12-01 20:32:01
Pentium10

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');
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!