title: try catch blocks with boost.Test
body: <p>I have a (Class member) function which I wish to avoid app crash due to ambiguity. For that purpose I have added a try catch bock as shown below:</p>
  
  <pre><code>void getGene(unsigned int position){
       T val;
       try {
          val =  _genome.at(_isCircular ? position % _genome.size() : position);
       }
       catch (std::exception&amp; e) {
           std::cerr &lt;&lt; "Error in [" &lt;&lt; __PRETTY_FUNCTION__ &lt;&lt; "]: " 
                     &lt;&lt; e.what()  &lt;&lt; std::endl;
           exit(1);
      }
      return val;
  }
  </code></pre>
  
  <p>Now, I wish to add a Boost unit test, which I thought of doing something like</p>
  
  <pre><code>BOOST_AUTO_TEST_CASE(nonCircularGenome_test){
  
     // set size to 10
     test.setSize(10);
     // set non circular
     test.setNonCircular();    
  
     // gene at site # 12 does not exist in a 10-site long genome, must throw an exception
     BOOST_CHECK_THROW(test.getGene(12), std::out_of_range);
  </code></pre>
  
  <p>The problem is, I can't get both these things work. The try-catch block works well in release setup. However, this test works, only if I remove the try-catch block and let the function throw the exception.</p>
  
  <p>What is the best way to get both these things working, so that a user is prompted with correct error on the go, while tests check explicitly on debug? One way is the use #ifdef/#endif <strong>DEBUG</strong> blocks, but I wish to avoid pre-processor macros.</p>
  
  <p>Thanks in advance,</p>
  
  <p>Nikhil</p>