title: How do I set a Python builtin Exception's message attribute when I raise it
body: <p>I know I can specify an arbitrary number of arguments to an Exception (or any subclass thereof) when I raise it, but I see that Exceptions have a message attribute which isn't populated.</p>
  
  <pre><code>def throw():
      raise Exception("This is my message", 10)
  
  try:
      throw()
  except Exception as E:
      print "message = ", E.message
      print E.args
  </code></pre>
  
  <p>produces</p>
  
  <pre><code>message = 
  ("This is my message", 10)
  </code></pre>
  
  <p>What I would like to do is raise a variety ValueErrors depending on how or why a value in my function isn't valid. I would also like to attach a code, so something like</p>
  
  <pre><code>raise ValueError(1, "You need to supply a string value")
  # or
  raise ValueError(2, "Not a valid place name") #but it is a valid string
  </code></pre>
  
  <p>I'm writing a code that runs callbacks supplied by the user, and I expect the user's functions to raise ValueErrors in certain situations, but their callback can also call into some library functions I provide, and I want to be able distinguish between the user's ValueErrors and Mine.</p>
  
  <p>I know I can subclass the ValueError and check for that exception type explicitly, but that seems like overkill. These are all errors with user supplied values after all, so I would like to use the first argument to the exception as a code, and then somehow set the message attribute explicitly</p>
  
  <pre><code>raise ValueError(10, message = "Error 10 is something quite specific")
  </code></pre>
  
  <p>The above doesn't work, because exceptions don't accept keyword arguments on <strong>init</strong>.</p>