title: Python conditional exception messages
body: <p>I'm using Python 2.7 and am new to custom exceptions. I've read up on them as much as I can but haven't found much help for this particular issue.</p>
  
  <p>I am calling an API which returns a status code with most responses. For example, 0 is 'Success', 1 is 'Wrong number of parameters', 2 is 'Missing parameter', etc.</p>
  
  <p>When I get a response, I check the status to make sure I don't continue if something is wrong. I've been raising a generic exception, for example:</p>
  
  <pre><code>if response.get('status') != 0:
      print 'Error: Server returned status code %s' % response.get('status')
      raise Exception
  </code></pre>
  
  <p>How can I create a custom exception that looks up what the status code is and returns it as part of the exception's error message? I envision something like:</p>
  
  <pre><code>if response.get('status') != 0:
      raise myException(response.get('status'))
  </code></pre>