Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a complete list of mongodb error codes?

Tags:

mongodb

To create custom error handling I would like to switch at the errorcode property of a MongoDbException.

Is there any official list of error codes?

I know 112 is a WriteConflict, 16608 means division by 0 and 16610 is a modulo by zero.

error_codes.yml is incomplete and lacks of 16608 and 16610.

like image 892
Christian Kuetbach Avatar asked Aug 31 '20 12:08

Christian Kuetbach


People also ask

How do I catch a MongoDB error?

For MongoDB, there is an internal system of error classification. MongoDB assigns different names and codes to errors that can be seen by console logging an error. By console logging the errors, you can see what the error stacktrace (the error metadata and where it occurs in your app) looks like.

What command will you use to list all available databases in MongoDB?

In MongoDB, you can use the show dbs command to list all databases on a MongoDB server. This will show you the database name, as well as the size of the database in gigabytes.

How do I show all collections in MongoDB shell?

To list all collections in Mongo shell, you can use the function getCollectionNames().

Where can I find error codes in MongoDB?

MongoDB server source code is publicly available, if you want to get information about a particular error, or get a list of all errors, going through the source is going to be your best bet. Per Daemon Painter's comment, there is an open docs ticket to provide a list of error codes.

Why am I getting a hostname error in mongod?

The specified options are in error or are incompatible with other options. Returned by mongod if there is a mismatch between hostnames specified on the command line and in the local.sources collection, in master/slave mode. The version of the database is different from the version supported by the mongod (or exe) instance.

When did MongoDB error-handling last update?

MongoDB Error-handling Notes Russell Bateman 10 June 2013 last update: Table of Contents Write concern Java driver Setting up to use MongoDB in Java Java Morphia Preformed static write concerns for Java (and Morphia)

What are the exceptions caught by MongoDB?

Exceptions caught include network, duplicate key and write-concern error. Journaled. Confirmation only after mongodhas written it to the journal. The operation should survive shutdown. Replica-acknowledged. Confirmation only after mongodhas reached one or more replica nodes.


1 Answers

I found a list here (the same as yours)link. In my case, We launched a lot of test scenarios and then i searched in logs all the possible codes. The ones that i found are :

  • 112 write conflict (when a transaction is failed)
  • 11000 Duplicate Key (when a unique constraint index is violated)
  • 211 or 11600 When mongo is down or i have a bad config

So If we don't have a better solution. All we can do is handling the most redundant cases. The other cases are handled as 500 server error.

like image 62
Isko Avatar answered Nov 23 '22 18:11

Isko