Entweder log oder rethrow diese Ausnahme

Mögliche Duplikate von Sonar beschweren sich über die Protokollierung und erneute auslösen der exception.

Dies ist mein code in einer Klasse:

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());
    }

und meine Logger-Klasse:

    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 verweist catch (final Exception e) und sagt Either log or rethrow this exception. Was denkst du?

InformationsquelleAutor Hesam | 2015-08-25

Schreibe einen Kommentar