-
Type: Improvement
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Error Handling
-
None
-
(copied to CRM)
Go 1.13 introduced a way to unwrap errors to get to the root error cause (seeĀ https://blog.golang.org/go1.13-errors). We should add an Unwrap method to all of our error types that wrap errors and also add a Wrapped field to mongo.CommandError as the operations layer reports network errors as a driver.Error with the NetworkError label. The driver.Error type already has a wrapped field so that can be directly copied in the replaceErrors function.
We should also change how we wrap certain errors. Specifically, when a context timeout is translated into a socket timeout, we should ensure the error returned to the user in the event of a timeout can be checked with errors.Is(err, context.DeadlineExceeded). This currently doesn't work because the user instead gets back whatever the net library returns.