Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我得到这个问题:
"Exception handlers should provide some context and preserve the original exception"
在这样的代码上:
catch (IOException e) { Log.e(AnkiDroidApp.TAG, "<actual message here"); }
我如何告诉 Sonar 我们的记录器不是 Logger,而是 Log?
原来我误解了声纳的抱怨。它并不期望记录器有一个特定的名称,而是希望代码将消息和异常本身都发送到记录器,如下所示:
catch (IOException e) { Log.e(AnkiDroidApp.TAG, "<actual message here", e); }