简体   繁体   English

如何处理使用GCP时可能出现的异常 API

[英]How to handle possible exceptions that might occur when using GCP API

I am working on a python script to monitor resources in GCP.我正在开发一个 python 脚本来监控 GCP 中的资源。 I used the GCP Python API's and completed my script but I can't find how to add exception handling to it.我使用了 GCP Python API 并完成了我的脚本,但我找不到如何为其添加异常处理。 I did the same for AWS and I found the exceptions that occur in each method I used in AWS through the documentation since it provided all the possible exceptions that can occur in each API Method.我对 AWS 做了同样的事情,我通过文档发现了我在 AWS 中使用的每个方法中发生的异常,因为它提供了每个 API 方法中可能发生的所有可能的异常。 Is there a similar documentation I can refer to when it comes to GCP?关于 GCP,我可以参考类似的文档吗? I can't find similar explanation in GCP documentation.我在 GCP 文档中找不到类似的解释。 For example in aws documentation: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.list_users例如在 aws 文档中: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/iam.html#IAM.Client.list_users

list users method exceptions列出用户方法异常

I want similar reference in GCP like this.我想要像这样在 GCP 中类似的参考。 Please help.请帮忙。

Reference link for the exceptions raised by Google API core & clients: Google API 核心和客户端引发的异常的参考链接:
https://googleapis.dev/python/google-api-core/latest/exceptions.html https://googleapis.dev/python/google-api-core/latest/exceptions.html

Core Library for Google Client Libraries: Google 客户端库的核心库:
Search this repository for sample code on exceptions.在此存储库中搜索有关异常的示例代码。
https://github.com/googleapis/python-api-core https://github.com/googleapis/python-api-core

Reference link for all api's and their associated python client libraries:所有 api 及其关联的 python 客户端库的参考链接:
https://cloud.google.com/python/docs/reference https://cloud.google.com/python/docs/reference
(For each service there is a link provided to the python client library. Clink on the link and search the repository for sample code on exceptions) (对于每个服务,都有一个指向 python 客户端库的链接。单击该链接并在存储库中搜索有关异常的示例代码)

Refer to the link below for more information on client libraries:有关客户端库的更多信息,请参阅以下链接:
https://cloud.google.com/apis/docs/cloud-client-libraries https://cloud.google.com/apis/docs/cloud-client-libraries

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

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