title: python: return exception from function
body: <p>suppose I have the following function:</p>
  
  <pre><code>def test():
    ...
    if x['error']:
      raise
  </code></pre>
  
  <p>This would raise an exception regardless if <code>x['error']</code> is defined or not.</p>
  
  <p>Instead if I try this, it doesn't throw any exception:</p>
  
  <pre><code>def test():
    ...
    try:
      if x['error']:
        raise
    except:
      return
  </code></pre>
  
  <p>How can I test for a specific value and return an exception if it is defined, and to return successfully if it is not defined?</p>