-
Type: Improvement
-
Resolution: Unresolved
-
Priority: Unknown
-
Affects Version/s: None
-
Component/s: None
-
None
There are currently a bunch of error constants (i.e. exported variables of type error) that we expose to allow users to check specific errors. However, users rarely want to check for invalid input at runtime because there's usually no way to remedy those. For example, if you pass "*" as the "name" to IndexView.DropOne you'll get a mongo.ErrMultipleIndexDrop. The only way to remedy that error is to pass a different string value for "name". It's unexpected that a user would be able to write an error handling block that could resolve that type of error, so it's unexpected that a user would check specifically for mongo.ErrMultipleIndexDrop.
Instead, users probably want to be able to check for the entire category of input errors.
E.g. use case of InvalidArgumentError.
var iv mongo.IndexView name := readInput() _, err := iv.DropOne(ctx, name) if errors.Is(err, mongo.InvalidArgumentError) { fmt.Println("Bad user input: %v", err) } if err != nil { fmt.Println("Unknown error: %v", err) }
- is related to
-
GODRIVER-1854 Make "ErrNilDocument" and "ErrNilValue" more specific
- Backlog