title: boost exception's error info
body: <p>When using <a href="http://www.boost.org/doc/libs/1_51_0/libs/exception/doc/boost-exception.html"><code>boost::exception</code></a>, what is the preferred way to know what data the exception is carrying? In the <a href="http://www.boost.org/doc/libs/1_51_0/libs/exception/doc/motivation.html">boost documentation</a> the following example is given:</p>
  
  <pre><code>catch( io_error &amp; e )
      {
      std::cerr &lt;&lt; "I/O Error!\n";
  
      if( std::string const * fn=get_error_info&lt;file_name&gt;(e) )
          std::cerr &lt;&lt; "File name: " &lt;&lt; *fn &lt;&lt; "\n";
  
      if( int const * c=get_error_info&lt;errno_code&gt;(e) )
          std::cerr &lt;&lt; "OS says: " &lt;&lt; strerror(*c) &lt;&lt; "\n";
      }
  </code></pre>
  
  <p>This seems to be a bit awkward, especially if the exception bubbled through a lot of layers and has a load of metadata theoretically available. So I guess it makes sense to document what the possible error infos are for each exception class. Then I probably also need documentation for some functions, about what information might be in the exceptions. In the end I feel like I have the exact same structure in documentation, as I would have in code if I just used something like the following struct:</p>
  
  <pre><code>struct FileException {
    string* filename; // NULL or string
  }
  </code></pre>
  
  <p>I could then change this information in a catch block:</p>
  
  <pre><code>catch (FileException&amp; e) {
    e.filename = filename;
    throw;
  }
  </code></pre>
  
  <p>This simple way I would get around most of the documentation, and profit from all of the safety (e.g. not trying to get filenames from <code>MathException</code>). Yet people use boost. Is there a big advantage of the dynamic approach that I'm missing? How do you document the error infos in your code?</p>