-
Type: New Feature
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.2.1
-
Component/s: Cluster Management
-
Labels:None
Hi,
We have an application that uses Mongodb as a backend for storage. We create a MongoClient, get the required MongoDatabase, then test the connection by performing a count command. The problem we're having is if there is no server listening at the specified address, or authentication fails, BaseCluster.selectServer will throw a MongoTimeoutException. We want to distinguish between various error conditions so that the user can be given a meaningful hint as to what can be done, but it seems like the only way to do this would be to do some String matching on the exception message, which we'd like to avoid.
Would it be acceptable to pass the actual ClusterDescription object back with the exception, perhaps as part of a new type of exception (e.g. MongoClusterTimeoutException) so that we have access to the ServerDescriptions and the original exception that ocurred (e.g. MongoSecurityException in the case of failed authentication)?
If not, is there a better way to distinguish between error conditions without needing to do matching on the exception message?