title: Avoiding "During handling of the above exception, another exception occurred" when catching and immediately raising exceptions
body: <pre><code>my_dictionary = {'a':1}
  try:
      my_dictionary['b']
  except KeyError as e:
      raise KeyError('Bad key:' + str(e))
  </code></pre>
  <p>That code, obviously, will raise a <code>KeyError</code>:</p>
  <pre><code>Traceback (most recent call last):
  
    File &quot;----.py&quot;, line 11, in &lt;module&gt;
      my_dictionary['b']
  
  KeyError: 'b'
  
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
  
    File &quot;----.py&quot;, line 13, in &lt;module&gt;
      raise KeyError('Bad key:' + str(e))
  
  KeyError: &quot;Bad key:'b'&quot;
  </code></pre>
  <p>While I understand the need for Python to state how the <code>except</code> part created its own error, I'd like for that first <code>KeyError</code> not to be shown. A workaround I came up with is this:</p>
  <pre><code>my_dictionary = {'a':1}
  err_msg = None
  try:
      my_dictionary['b']
  except KeyError as e:
      err_msg = str(e)
  if type(err_msg) != type(None):
      raise KeyError('Bad key:' + err_msg)
  </code></pre>
  <p>which shortens the error message to this:</p>
  <pre><code>Traceback (most recent call last):
  
    File &quot;----.py&quot;, line 23, in &lt;module&gt;
      raise KeyError('Bad key:' + err_msg)
  
  KeyError: &quot;Bad key:'b'&quot;
  </code></pre>
  <p>Is there a more Pythonic way of doing this?</p>