【发布时间】:2015-11-18 18:19:46
【问题描述】:
Sonar complaining about logging and rethrowing the exception 可能重复。
这是我在课堂上的代码:
try
{
this.processDeepLinkData(data);
}
catch (final Exception e)
{
// Error while parsing data
// Nothing we can do
Logger.error(TAG, "Exception thrown on processDeepLinkData. Msg: " + e.getMessage());
}
还有我的 Logger 类:
import android.content.Context;
import android.util.Log;
import com.crashlytics.android.Crashlytics;
public final class Logger
{
/**
* Convenience method.
*
* @see Logger#log(String, String)
*/
public static void error(final String tag, final String msg)
{
if (Logger.DEBUG)
{
Log.e(tag, "" + msg);
}
else
{
Logger.log(tag, "" + msg);
}
}
private static void log(final String tag, final String msg)
{
Crashlytics.log(tag + ": " + msg);
}
}
Sonar 指向catch (final Exception e) 并说Either log or rethrow this exception。你怎么看?
【问题讨论】:
标签: java android sonarqube code-analysis sonar-runner