title: C++ "Proper" way of dealing with exceptions
body: <p>I'm programming a ROS Node which will likely be used by others and that's why I want to follow common guidelines. Sometimes I would like to add additional information to the exception, but I'm not sure how to do it. Here's an example of where that would be handy:</p>
  
  <p>My ROS node connects to a serial device using the boost library. Under linux the permissions need to be set for /dev/ttyUSB0 for example or boost won't be able to open a serial connection and terminate the program.</p>
  
  <p>Here's the original exception message copied from the console:</p>
  
  <pre><code>terminate called after throwing an instance of 'boost::exception_detail::clone_impl&lt;boost::exception_detail::error_info_injector&lt;boost::system::system_error&gt; &gt;'
  what():  open: Permission denied
  Aborted (core dumped)
  </code></pre>
  
  <p>As I know what the problem might be, I want to provice the user with additional information. That's why I wrapped the line causing the problem with a try/catch block:</p>
  
  <pre><code>try{
      serial = new boost::asio::serial_port (io, port);
  }
  catch(const std::exception&amp; e)
  {
      cerr &lt;&lt; "EXCEPTION CAUGHT: Boost::asio::serial_port could not open a connection. Make sure that you have read/write access to the serial port (run: sudo chmod a+rw /dev/ttyUSB0)" &lt;&lt; endl;
      cerr &lt;&lt; endl &lt;&lt; "Original exception:" &lt;&lt; endl;
      throw;
  }
  </code></pre>
  
  <p>Is this a good or bad way of dealing with this situation? Thanks in advance</p>