title: Python exception chaining
body: <p>Is there a standard way of using exception chains in Python?  Like the Java exception 'caused by'?</p>
  
  <p>Here is some background.</p>
  
  <p>I have a module with one main exception class <code>DSError</code>:</p>
  
  <pre><code> class DSError(Exception):
       pass
  </code></pre>
  
  <p>Somewhere within this module there will be:</p>
  
  <pre><code>try:
      v = my_dict[k]
      something(v)
  except KeyError as e:
      raise DSError("no key %s found for %s" % (k, self))
  except ValueError as e:
      raise DSError("Bad Value %s found for %s" % (v, self))
  except DSError as e:
      raise DSError("%s raised in %s" % (e, self))
  </code></pre>
  
  <p>Basically this snippet should throw only DSError and tell me what happened and why.  The thing is that the try block might throw lots of other exceptions, so I'd prefer if I can do something like:</p>
  
  <pre><code>try:
      v = my_dict[k]
      something(v)
  except Exception as e:
      raise DSError(self, v, e)  # Exception chained...
  </code></pre>
  
  <p>Is this standard pythonic way?  I did not see exception chains in other modules so how is that done in Python?</p>