kmesh-net/kmesh

Improper Error Wrapping (%w)

开放

#1,608 创建于 2026年3月7日

 (3 条评论) (0 个反应) (1 位负责人)Go (239 个派生)auto 404
good first issue

仓库指标

星标
 (739 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

Currently, when Kmesh encounters an error and passes it up to another part of the program, it often converts that error into a simple text message.

While this looks fine in the logs, it creates a problem for the code itself: it "destroys" the original error's identity. If one part of Kmesh needs to know exactly what went wrong (for example, distinguishing between a "Network Timeout" and an "Invalid Secret"), it can no longer do that because the error has been turned into a generic string of text.

By using "Error Wrapping" instead, we allow the program to look inside an error message to see the original cause. This enables "smarter" error handling, where the system can automatically retry certain types of failures while stopping for others.

Solution: We need to update the way errors are formatted across the project. Instead of just printing the error's text, we should "wrap" the original error so that its type and data remain accessible to other parts of the system.

贡献者指南