File tree Expand file tree Collapse file tree 3 files changed +24
-11
lines changed
Expand file tree Collapse file tree 3 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ now accepts an `address` parameter.
8787:mod: `~pymongo.errors ` Changes
8888..............................
8989
90- The exception class ``UnsupportedOption `` is deleted.
90+ The exception classes ``UnsupportedOption `` and `` TimeoutError `` are deleted.
9191
9292:mod: `~gridfs ` Changes
9393......................
Original file line number Diff line number Diff line change @@ -126,12 +126,21 @@ class ExecutionTimeout(OperationFailure):
126126 """
127127
128128
129- class TimeoutError (OperationFailure ):
130- """DEPRECATED - will be removed in PyMongo 3.0. See WTimeoutError instead.
129+ class WriteConcernError (OperationFailure ):
130+ """Base exception type for errors raised due to write concern.
131+
132+ .. versionadded:: 3.0
133+ """
134+
135+
136+ class WriteError (OperationFailure ):
137+ """Base exception type for errors raised during write operations.
138+
139+ .. versionadded:: 3.0
131140 """
132141
133142
134- class WTimeoutError (TimeoutError ):
143+ class WTimeoutError (WriteConcernError ):
135144 """Raised when a database operation times out (i.e. wtimeout expires)
136145 before replication completes.
137146
@@ -142,7 +151,7 @@ class WTimeoutError(TimeoutError):
142151 """
143152
144153
145- class DuplicateKeyError (OperationFailure ):
154+ class DuplicateKeyError (WriteError ):
146155 """Raised when an insert or update fails due to a duplicate key error."""
147156
148157
Original file line number Diff line number Diff line change 2424from bson .son import SON
2525from pymongo .errors import (CursorNotFound ,
2626 DuplicateKeyError ,
27- OperationFailure ,
2827 ExecutionTimeout ,
29- WTimeoutError ,
30- NotMasterError )
28+ NotMasterError ,
29+ OperationFailure ,
30+ WriteError ,
31+ WriteConcernError ,
32+ WTimeoutError )
3133from pymongo .message import query
3234
3335
@@ -244,13 +246,15 @@ def _check_write_command_response(results):
244246 error ["index" ] += offset
245247 if error .get ("code" ) == 11000 :
246248 raise DuplicateKeyError (error .get ("errmsg" ), 11000 , error )
249+ raise WriteError (error .get ("errmsg" ), error .get ("code" ), error )
247250 else :
248251 error = result ["writeConcernError" ]
249252 if "errInfo" in error and error ["errInfo" ].get ('wtimeout' ):
250253 # Make sure we raise WTimeoutError
251- raise WTimeoutError (error .get ("errmsg" ),
252- error .get ("code" ), error )
253- raise OperationFailure (error .get ("errmsg" ), error .get ("code" ), error )
254+ raise WTimeoutError (
255+ error .get ("errmsg" ), error .get ("code" ), error )
256+ raise WriteConcernError (
257+ error .get ("errmsg" ), error .get ("code" ), error )
254258
255259
256260def _fields_list_to_dict (fields , option_name ):
You can’t perform that action at this time.
0 commit comments