title: How should you handle MongoDB-Exceptions in Java?
body: <p>I want to handle exceptions, which are thrown from a query (find(...).first()) to MongoDB (Driver 3.7) in Java (the database is not stored locally). However there are no possible exceptions named in the <a href="https://mongodb.github.io/mongo-java-driver/3.7/javadoc/com/mongodb/DBCollection.html#find-com.mongodb.DBObject-" rel="nofollow noreferrer">JavaDocs</a> and also in the MongoDB documentaton itself. Can there really occur no exceptions? I doubt that, because I think there could occur e.g. some network errors.</p>
  
  <p>My queries look something like this:</p>
  
  <pre><code>final MongoCollection&lt;Document&gt; collection = database.getCollection("my-collection");
  final Bson bsonFilter = Filters.eq("someName", "test");
  final Document result = collection.find(bsonFilter).first();
  </code></pre>