-
Type:
Improvement
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Go Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Context
The processWriteError func converts all errors chains that contain type driver.WriteCommandError into a mongo.WriteException, but discards the error chain. As a result, the additional context from all wrapped and joined errors is completely missing from the returned error. That means that joined retry errors (added with GODRIVER-3600) are never returned from write methods (e.g. InsertOne, UpdateOne, etc). We need to refactor processWriteError to maintain the error chains, similar to how wrapErrors works.
Definition of done
- Update processWriteError to wrap errors, not replace them.
- Add an Unwrap() error func to mongo.WriteException and return the original error chain that was passed to processWriteError.
- Update the mongo.WriteException error message to prevent duplication with the wrapped errors.
- Replace all direct error type assertions for the mongo.WriteException error type with calls to errors.As.
- 24 type assertions, all in tests. See the results here.
Pitfalls
What should the implementer watch out for? What are the risks?
- related to
-
GODRIVER-3600 Join all errors that happen during retries
-
- In Code Review
-