Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2469

Distinguish between error conditions when server selection fails

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • 3.2.1
    • Cluster Management
    • None

    Description

      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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            jmatsuok Joshua Matsuoka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: