java - Either log or rethrow this exception -


possible duplicate of sonar complaining logging , rethrowing exception.

this code in class:

try     {         this.processdeeplinkdata(data);     }     catch (final exception e)     {         // error while parsing data         // nothing can         logger.error(tag, "exception thrown on processdeeplinkdata. msg: " + e.getmessage());     } 

and logger class:

    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 pointing catch (final exception e) , says either log or rethrow exception. think?

if @ rule description : http://nemo.sonarqube.org/coding_rules#rule_key=squid%3as1166

and title :

exception handlers should preserve original exception

in case taking care of message of exception, not preserving eventual stacktrace (and root cause of failure).

this rule detects not using caught exception entire object in catch block.

this might not suitable in case : either mark rule "won't fix" or deactivate in quality profile.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -