title: Implementing a good C++0x error_condition?
body: <p><strong>I try to figure out how the new <code>system_error</code> together with <code>error_code</code>, <code>error_category</code> and not the least the (meant to implement <em>portable</em> error reporting) <code>error_condition</code> should be used.</strong></p>
  
  <p>I think by reading <a href="http://en.highscore.de/cpp/boost/errorhandling.html" rel="noreferrer">boost.system</a> I understand how I should use <code>error_codes</code> and <code>error_category</code>. The description leaves out how this is used in conjunction when throwing an exception with ´system_error`, but from the interface from that class I can guess.</p>
  
  <pre><code>class system_error : public runtime_error {
  public:
    // [...]
    system_error(error_code ec, const string&amp; what_arg);
    system_error(int ev, const error_category&amp; ecat, const string&amp; what_arg);
    system_error(int ev, const error_category&amp; ecat);
    // [...]
  </code></pre>
  
  <p>So, I throw a <code>system_error</code>-exception with the right <code>int</code>+<code>error_category</code> or <code>error_code</code> with its <code>error_category()</code>-method.</p>
  
  <p><strong>But whats the way to provide the <em>portable</em> interface with <code>error_condition</code>?</strong></p>
  
  <p>Both <code>error_code</code> <em>and</em> <code>error_category</code> both have method <code>default_error_condition</code>:</p>
  
  <pre><code>class error_category {
  public:
    // [...]
    virtual error_condition default_error_condition(int ev) const noexcept;
    // [...]
  
  class error_code {
  public:
    // [...]
    error_condition default_error_condition(int ev) const noexcept;
    // [...]
  </code></pre>
  
  <p>The <code>error_category</code>-Instances should be pre-created, for example (<em>user-code</em>):</p>
  
  <pre><code>struct AppCategory : public error_category { 
    const char *name() const noexcept override {
      return "application"; } 
    string message(int ev) const override {
      switch(ev) {
        case 14: return "error message";
        default: return "???";
      }
    } 
    error_condition default_error_condition(int ev) const noexcept override {
       ... ??? ...
    }
  };
  </code></pre>
  
  <p>My questions implementing this:</p>
  
  <ul>
  <li>Should I implement <code>default_error_condition</code> in <code>error_category</code>, and how?</li>
  <li>Or how do I connect <code>error_codes</code> to the proper <code>error_conditions</code>,</li>
  <li>and should I pre-construct <code>error_condition</code> instances?</li>
  <li>A class <code>error_code</code> is not supposed to be provided by the user (me), right?</li>
  </ul>
  
  <p><strong>Is there a good example where I can take a look at code how <code>error_condition</code> is supposed to be extended by the user</strong>, in conjunction with <code>system_error</code>-exceptions?</p>