我们应该使用拦截器在GRPC客户端中进行错误处理吗?

发布于 2025-02-14 00:37:21 字数 939 浏览 2 评论 0原文

我有一个ASP.NET Core 6 WebAPI,该WebAPI将GRPC调用到GRPC服务。

我想实现错误处理,以便它过滤敏感信息,并在发生错误时仅返回有用的数据。

来自 - 我知道在 grpc服务器上拦截器是唯一的方法捕获GRPC错误。

但是,在客户端上,任何rpcexception都将被所述的一般例外柄抓住,如 shere

我看到有一个示例此处用于客户端拦截器。

但是,由于我不需要记录每个呼叫 - 出于我的目的,我没有意义。

有人看到使用拦截器在 grpc客户端上捕获错误的理由吗?

I have an Asp.Net Core 6 WebApi which makes gRPC calls to a Grpc Service.

I want to implement error handling so that it filters out sensitive information and returns only useful data when an error occurs.

From the documentation - I understand that on the Grpc Server an Interceptor is the only way to catch a gRPC error.

On the client, however, any RpcException will be caught by the general exception handers as described here.

I see there is an example here for Client side interceptor.

But since I don't need to log every call - I see no point in it for my purposes.

Does anyone see a reason to use an Interceptor to catch errors on the Grpc Client?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文