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.
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.
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.
To list all collections in Mongo shell, you can use the function getCollectionNames().
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.
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.
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)
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.
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 :
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With