googleapis / googleapis/google-cloud-python

Replace `except:` and `except Exception:` with a more granular exception

未关闭
#16,201 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
priority: p2 type: process
主要语言
Python
星标
5.4k
派生
1.8k
平均合并
3 天 4 小时
30 天内合并 PR
122

描述

See feedback from gemini in PR https://github.com/googleapis/gapic-generator-python/pull/2549:

https://github.com/googleapis/gapic-generator-python/pull/2549#discussion_r2747934082

```
The except: on the next line is a bare except, which is a bad practice as it catches all exceptions, including system-exiting ones like SystemExit and KeyboardInterrupt. This can make debugging difficult and hide underlying issues. It would be better to catch a more specific exception, like Exception.

While there's a TODO in the template to remove this try/except block, improving it in the meantime would be beneficial.

This change should be applied to the template file: gapic/templates/%namespace/%name_%version/%sub/services/%service/_shared_macros.j2.

Suggested change in the template:

except Exception:
```

We should remove all usages of `except:` and replace them with `except Exception:` or a more granular exception

Search results for `except:`

https://github.com/search?q=repo%3Agoogleapis%2Fgapic-generator-python%20except%3A&type=code

Search results for `except Exception:`
https://github.com/search?q=repo%3Agoogleapis%2Fgapic-generator-python+%22except+Exception%3A%22&type=code

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。