[GODRIVER-378] Unconnected Client should return a mongo level error, not topology level error Created: 23/Apr/18  Updated: 28/Oct/23  Resolved: 15/Nov/18

Status: Closed
Project: Go Driver
Component/s: Error Handling
Affects Version/s: None
Fix Version/s: 0.0.18

Type: Improvement Priority: Major - P3
Reporter: Kristofer Brandow (Inactive) Assignee: Isabella Siu (Inactive)
Resolution: Fixed Votes: 0
Labels: neweng, newgrad
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: GODRIVER-114

 Description   

Currently when a user attempts to use a newly instantiated Client, they currently receive topology.ErrTopologyClosed error. This is confusing for users of the high level API since they don't have in-depth knowledge of a topology. We can solve this in one of two ways:

  1. Check for ErrTopologyClosed and transform it into a ErrClientDisconnected error
  2. Add a connection state to Client and check if the Client is connected before performing an operation.

While the second option provides a faster path to failure and is less invasive, it introduces a race condition, where users that call Disconnect might still see a topology.ErrTopologyClosed error. Eventually, we'll need to wrap most of the core API packages' errors, so starting with ErrTopologyClosed seems like a sensible thing to do.

A general error handling function can be created in the mongo package or attached to the *mongo.Collection type to handle the transformation.



 Comments   
Comment by Githook User [ 15/Nov/18 ]

Author:

{'name': 'Isabella Siu', 'email': 'isabella.siu@10gen.com'}

Message: GODRIVER-378 Unconnected Client returns mongo.ErrClientDisconnected

Change-Id: I7391f8f56521b09cec4203082ce57c44d49b87fb
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/e2d5932c4128d954de6d6ed202b120b5f7069989

Generated at Thu Feb 08 08:34:05 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.