title: Get the duplicate value on DuplicateKeyError
body: <p>In pymongo, when a <code>DuplicateKeyError</code> caught, what's the proper way to find out the duplicate value behind the the exception?</p>
  
  <p>Currently I do this</p>
  
  <pre><code>try:
      db.coll.insert({key: ['some_value', 'some_value_1']})
  except pymongo.errors.DuplicateKeyError, e:
      dups = re.findall(r'\{\ +:\ +"(.*)"\ +\}$', e.message)
      if len(dups) == 1:
          print dups[0]
  </code></pre>
  
  <p>It seems to work, but is there any easier way, like</p>
  
  <pre><code>try:
      db.coll.insert({key: ['some_value', 'some_value_1']})
  except pymongo.errors.DuplicateKeyError, e:
      print e.dup_val
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>It's a concurrent app, so check duplicates before insert might fail.</p>
  
  <p>The field is an array, so it's hard to find out which one is the duplicate value.</p>