-
Type:
New Feature
-
Resolution: Unresolved
-
Priority:
Unknown
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Go Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Context
It's not possible for a user to check the error code of an error passed by event.CommandFailedEvent without relying on the experimental API:
derr, ok := evt.Failure.(driver.Error)
if ok {
fmt.Println(derr.Code)
}
An example use case are the metrics implementation for otelmongo which requires providing a database status code, particularly for failures.
Definition of done
The team has considered two solutions.
1. Add a Codes []string field to event.CommandFailedEvent
2. Support for this in the stable API, such as with the function mongo.ErrorCodes():
codes := mongo.ErrorCodes(err) _ = codes
We should start with (1) and if that presents difficulties, attempt (2).
Pitfalls
We probably don't want to support a huge set of functions to parse information off arbitrary errors. Error codes feel unique, however, in that they can be acted upon.
- has to be done after
-
GODRIVER-3664 Include the write concern error in server error message if present
-
- Backlog
-
- is related to
-
DRIVERS-3339 Expose optional error codes on CommandFailedEvent
-
- Needs Triage
-
- related to
-
GODRIVER-3678 Review OTEL PR 7983
-
- Closed
-