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

后端 未结 2 571
走了就别回头了
走了就别回头了 2021-01-21 05:31

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

相关标签:
2条回答
  • 2021-01-21 05:55

    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);
    
    0 讨论(0)
  • 2021-01-21 06:09

    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');
    }
    
    0 讨论(0)
提交回复
热议问题