title: Why does squid:S1166 not accept exception messages only when logging caught exceptions?
body: <p>Quote from the description of the rule (SonarQube 4.5.5):</p>
  
  <pre><code>// Noncompliant - exception is lost (only message is preserved)   
  try { /* ... */ } 
  catch (Exception e) { LOGGER.info(e.getMessage()); }
  </code></pre>
  
  <p>By providing the exception class to the logger a stack trace is written to the logs.</p>
  
  <p>The problem in our code base is this:
  By following the <a href="http://martinfowler.com/bliki/TellDontAsk.html" rel="noreferrer">Tell, don't ask</a> principle, we use checked exceptions as part of the, what we consider, normal execution paths and we don't want them to result in unreasonably large log messages. </p>
  
  <p>A few examples: Servers responding with error codes, database statement executions failing on optimistic locking (concurrent users)...</p>
  
  <p><strong>My suggestion: Split this case in two.</strong></p>
  
  <pre><code>// Noncompliant - exception is lost (only message is preserved)
  try { /* ... */ } 
  catch (Exception e) { LOGGER.info(e.getMessage()); } 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>// Compliant - exception is lost (only message is preserved) but there is business logic handling the situation      
  
  try { 
  /* ... */  
  } catch (Exception e) {   
     LOGGER.info(e.getMessage());  
     */ exception handling  */  
  }
  </code></pre>
  
  <p>The rule <em>squid:S00108</em> (code blocks must not be empty) would not catch the problem since there is a logging statement.</p>
  
  <p><strong>Is this not reasonable? Have I missed something of importance?</strong></p>
  
  <p>Note: I've rewritten the question to clarify my use case</p>