简体   繁体   English

谷歌云 Function 捕获 BQ 存储过程异常

[英]Google Cloud Function to catch BQ Stored proc exception

I am calling BQ Stored proc via Cloud function and have below try catch block我正在通过 Cloud function 调用 BQ Stored proc,并在下面有 try catch 块

try:

    sql = """CALL `utl.##`(NULL, 1, 3);"""
    job = client.query(sql)
    job.result()
    print("job executed for query:{}".format(sql))
except Exception as e:
    print("error message:  "+job.error_result['message'])
    print(job.exception())

Stored Proc job status is success but one of the statement failed and throw some exception.存储的 Proc 作业状态为成功,但其中一条语句失败并引发一些异常。 I would like to capture that in Cloud function.我想在 Cloud function 中捕获它。 Is there any way?有什么办法吗?

Solved.. I was able to capture all errors in CF with the change in BQ stored Proc.已解决.. 我能够通过 BQ 存储的 Proc 的更改来捕获 CF 中的所有错误。 By properly raising exception message.通过适当地引发异常消息。

EXCEPTION WHEN ERROR THEN
select @@error.message
with 
 EXCEPTION WHEN ERROR THEN  
    RAISE USING MESSAGE = @@error.message ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM