Understand the MongoDB Node.js Driver error hierarchy
mainAll errors in the Node.js driver derive from the MongoError class. While MongoError is the base, it should never be directly instantiated.
There are five primary error branches:
MongoDriverError: Errors originating in the driver or caused by incorrect driver usage. This is the most common branch for developers.MongoNetworkError: Errors preventing connection to a MongoDB server.MongoServerError: Errors wrapping responses received directly from the MongoDB server.MongoSystemError: Errors originating from faulty environment setup (e.g.,MongoServerSelectionError).MongoCryptError: Errors thrown from client-side encryption logic.