Skip to content

Commit

Permalink
Annotate BSON errors also
Browse files Browse the repository at this point in the history
Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>
  • Loading branch information
tvansteenburgh committed Mar 13, 2013
1 parent bc966c3 commit 6f4662b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ming/session.py
Expand Up @@ -2,6 +2,8 @@
import logging
from functools import update_wrapper

import bson.errors

import pymongo
import pymongo.errors

Expand All @@ -18,8 +20,8 @@ def annotate_doc_failure(func):
def wrapper(self, doc, *args, **kwargs):
try:
return func(self, doc, *args, **kwargs)
except pymongo.errors.OperationFailure, opf:
opf.args = opf.args + (('doc: ' + str(doc)),)
except (pymongo.errors.OperationFailure, bson.errors.BSONError) as e:
e.args = e.args + (('doc: ' + str(doc)),)
raise
return update_wrapper(wrapper, func)

Expand Down

0 comments on commit 6f4662b

Please sign in to comment.