title: Custom exception codes and messages in Python 3.4
body: <p>I'd like to have something like a custom error code/message database and use it when raising exceptions <strong>(in Python 3.4)</strong>. So I did the following:</p>
  
  <pre><code>class RecipeError(Exception):
  
      # Custom error codes
      ERRBADFLAVORMIX = 1
      ERRNOINGREDIENTS = ERRBADFLAVORMIX + 1
  
      # Custom messages
      ERRMSG = {ERRBADFLAVORMIX: "Bad flavor mix",
                ERRNOINGREDIENTS: "No ingredients to mix"}
  
  raise RecipeError(RecipeError.ERRMSG[RecipeError.ERRBADFLAVORMIX])
  </code></pre>
  
  <p>This works as expected, but the <code>raise</code> statement is just monstrous. Sure, I could have stored the values in a more compact way, but what I really want to know is: <strong>Can I just do something like <code>raise RecipeError(code)</code> and leave the work of getting the message to RecipeError?</strong></p>